[xwiki-users] outputting cache-related headers from XWiki
Hello list, as I am slowly realizing, there's no way to prevent the output of the following headers which basically say that no client or proxy caching should be done. I agree that the default policy should be to not cache but it should be possible to allow to cache. Even changing the header values with: $response.setHeader("Cache-Control","max-age=60, public") fails because it adds no-cache to the front. $reponse.setDateHeader("Expires",someDate) seems to work. This is quite odd I have to say. Should I hunt somewhere else? I fear I need to dig into the servlets. paul
(moving to devs since it's an internal issue): the method XWikiServletResponse.setHeader was calling addHeader. http://jira.xwiki.org/jira/browse/XWIKI-6106 is opened. (it concerns the trunk as well). Since I applied this fix on my development machine, I can set a cache-header! paul Le 14 mars 2011 à 14:47, Paul Libbrecht a écrit :
as I am slowly realizing, there's no way to prevent the output of the following headers which basically say that no client or proxy caching should be done. I agree that the default policy should be to not cache but it should be possible to allow to cache.
Even changing the header values with: $response.setHeader("Cache-Control","max-age=60, public") fails because it adds no-cache to the front.
$reponse.setDateHeader("Expires",someDate) seems to work.
This is quite odd I have to say. Should I hunt somewhere else? I fear I need to dig into the servlets.
For the sake of the users list... once the issue below is fixed (I hope 3.0), I can set a correct cache header of one minute with the following velocity: $response.setHeader("Cache-Control","max-age=60, public") $response.setHeader("Pragma","-") #set($expires = $util.getDate().getTime()) #set($expires = $expires+60000) #set($expires =$util.getDate($expires)) $response.setDateHeader("Expires",$expires.getTime()) (the magic with the addition that has to take place in set took me some time... ggrrrrr) paul Le 14 mars 2011 à 18:23, Paul Libbrecht a écrit :
(moving to devs since it's an internal issue): the method XWikiServletResponse.setHeader was calling addHeader.
http://jira.xwiki.org/jira/browse/XWIKI-6106 is opened. (it concerns the trunk as well).
Since I applied this fix on my development machine, I can set a cache-header!
paul
Le 14 mars 2011 à 14:47, Paul Libbrecht a écrit :
as I am slowly realizing, there's no way to prevent the output of the following headers which basically say that no client or proxy caching should be done. I agree that the default policy should be to not cache but it should be possible to allow to cache.
Even changing the header values with: $response.setHeader("Cache-Control","max-age=60, public") fails because it adds no-cache to the front.
$reponse.setDateHeader("Expires",someDate) seems to work.
This is quite odd I have to say. Should I hunt somewhere else? I fear I need to dig into the servlets.
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
On 03/14/2011 07:33 PM, Paul Libbrecht wrote:
For the sake of the users list... once the issue below is fixed (I hope 3.0), I can set a correct cache header of one minute with the following velocity:
$response.setHeader("Cache-Control","max-age=60, public") $response.setHeader("Pragma","-") #set($expires = $util.getDate().getTime()) #set($expires = $expires+60000) #set($expires =$util.getDate($expires)) $response.setDateHeader("Expires",$expires.getTime())
(the magic with the addition that has to take place in set took me some time... ggrrrrr)
You could have used the http://velocity.apache.org/tools/devel/generic/MathTool.html . Hope this helps, Marius
paul
Le 14 mars 2011 à 18:23, Paul Libbrecht a écrit :
(moving to devs since it's an internal issue): the method XWikiServletResponse.setHeader was calling addHeader.
http://jira.xwiki.org/jira/browse/XWIKI-6106 is opened. (it concerns the trunk as well).
Since I applied this fix on my development machine, I can set a cache-header!
paul
Le 14 mars 2011 à 14:47, Paul Libbrecht a écrit :
as I am slowly realizing, there's no way to prevent the output of the following headers which basically say that no client or proxy caching should be done. I agree that the default policy should be to not cache but it should be possible to allow to cache.
Even changing the header values with: $response.setHeader("Cache-Control","max-age=60, public") fails because it adds no-cache to the front.
$reponse.setDateHeader("Expires",someDate) seems to work.
This is quite odd I have to say. Should I hunt somewhere else? I fear I need to dig into the servlets.
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
On Mar 15, 2011, at 8:24 AM, Marius Dumitru Florea wrote:
On 03/14/2011 07:33 PM, Paul Libbrecht wrote:
For the sake of the users list... once the issue below is fixed (I hope 3.0), I can set a correct cache header of one minute with the following velocity:
$response.setHeader("Cache-Control","max-age=60, public") $response.setHeader("Pragma","-") #set($expires = $util.getDate().getTime()) #set($expires = $expires+60000) #set($expires =$util.getDate($expires)) $response.setDateHeader("Expires",$expires.getTime())
(the magic with the addition that has to take place in set took me some time... ggrrrrr)
You could have used the http://velocity.apache.org/tools/devel/generic/MathTool.html .
Paul, would be great to add this as a snippet on http:/extensions.xwiki.org ... :) Thanks -Vincent
Hope this helps, Marius
paul
Le 14 mars 2011 à 18:23, Paul Libbrecht a écrit :
(moving to devs since it's an internal issue): the method XWikiServletResponse.setHeader was calling addHeader.
http://jira.xwiki.org/jira/browse/XWIKI-6106 is opened. (it concerns the trunk as well).
Since I applied this fix on my development machine, I can set a cache-header!
paul
Le 14 mars 2011 à 14:47, Paul Libbrecht a écrit :
as I am slowly realizing, there's no way to prevent the output of the following headers which basically say that no client or proxy caching should be done. I agree that the default policy should be to not cache but it should be possible to allow to cache.
Even changing the header values with: $response.setHeader("Cache-Control","max-age=60, public") fails because it adds no-cache to the front.
$reponse.setDateHeader("Expires",someDate) seems to work.
This is quite odd I have to say. Should I hunt somewhere else? I fear I need to dig into the servlets.
On Mar 15, 2011, at 8:24 AM, Marius Dumitru Florea wrote:
On 03/14/2011 07:33 PM, Paul Libbrecht wrote:
[...] (the magic with the addition that has to take place in set took me some time... ggrrrrr)
You could have used the
http://velocity.apache.org/tools/devel/generic/MathTool.html .
Thanks for the suggestion Marius, unfortunately, the math-tool is not available in xwiki-1.5-curriki... Le 15 mars 2011 à 08:31, Vincent Massol a écrit :
Paul, would be great to add this as a snippet on http:/extensions.xwiki.org ... :)
Thanks for the suggestion, done at: http://extensions.xwiki.org/xwiki/bin/view/Extension/Caching-Headers paul
On Mar 15, 2011, at 11:59 AM, Paul Libbrecht wrote:
On Mar 15, 2011, at 8:24 AM, Marius Dumitru Florea wrote:
On 03/14/2011 07:33 PM, Paul Libbrecht wrote:
[...] (the magic with the addition that has to take place in set took me some time... ggrrrrr)
You could have used the
http://velocity.apache.org/tools/devel/generic/MathTool.html .
Thanks for the suggestion Marius, unfortunately, the math-tool is not available in xwiki-1.5-curriki...
Le 15 mars 2011 à 08:31, Vincent Massol a écrit :
Paul, would be great to add this as a snippet on http:/extensions.xwiki.org ... :)
Thanks for the suggestion, done at: http://extensions.xwiki.org/xwiki/bin/view/Extension/Caching-Headers
Thanks. The title says: "a simple example of exposing correct caching headers" Which suggests that the default way xwiki does it is wrong and this is a patch. Could you explain more in the snippet when someone would use this snippet vs not doing anything (ie do what XWiki provides by default)? Thanks -Vincent
Le 15 mars 2011 à 12:07, Vincent Massol a écrit :
Thanks for the suggestion, done at: http://extensions.xwiki.org/xwiki/bin/view/Extension/Caching-Headers
which you moved to: http://extensions.xwiki.org/xwiki/bin/view/Extension/Add+Caching+Headers I am not sure this a good idea since "Adding" is precisely what it was doing inefficiently before the bug is addressed, moreover this snippets does not add any new header, it changes headers that were already output saying to not cache. I would prefer Caching-Headers (or Caching+Headers or...). Shall I move it again? I realize I need to adjust wording again for it though.
Thanks. The title says: "a simple example of exposing correct caching headers" Which suggests that the default way xwiki does it is wrong and this is a patch.
That is my feeling but there's a rationale behind both approaches. I have now commented on the default policy of xwiki (which guarantees the best dynamicity). paul
Could you explain more in the snippet when someone would use this snippet vs not doing anything (ie do what XWiki provides by default)?
On Mar 15, 2011, at 12:23 PM, Paul Libbrecht wrote:
Le 15 mars 2011 à 12:07, Vincent Massol a écrit :
Thanks for the suggestion, done at: http://extensions.xwiki.org/xwiki/bin/view/Extension/Caching-Headers
which you moved to:
http://extensions.xwiki.org/xwiki/bin/view/Extension/Add+Caching+Headers
I am not sure this a good idea since "Adding" is precisely what it was doing inefficiently before the bug is addressed, moreover this snippets does not add any new header, it changes headers that were already output saying to not cache. I would prefer Caching-Headers (or Caching+Headers or...).
Well I aligned it with the "rule" we've used for naming extensions and scripts which is: * Words separated by spaces * Mention action for scripts The idea is when you look at http://extensions.xwiki.org/xwiki/bin/view/Main/ you get some understanding about what the snippet does. We can rename to Set Caching Headers or Adjust Caching Headers or Set/Add/Adjust Cache Headers (not sure we need the -ing ending).
Shall I move it again? I realize I need to adjust wording again for it though.
Thanks. The title says: "a simple example of exposing correct caching headers" Which suggests that the default way xwiki does it is wrong and this is a patch.
That is my feeling but there's a rationale behind both approaches. I have now commented on the default policy of xwiki (which guarantees the best dynamicity).
Thanks! I'm going to add other options on that page: * Rendering cache * Cache macro Thanks -Vincent
paul
Could you explain more in the snippet when someone would use this snippet vs not doing anything (ie do what XWiki provides by default)?
Le 15 mars 2011 à 12:33, Vincent Massol a écrit :
I would prefer Caching-Headers (or Caching+Headers or...).
Well I aligned it with the "rule" we've used for naming extensions and scripts which is: * Words separated by spaces * Mention action for scripts The idea is when you look at http://extensions.xwiki.org/xwiki/bin/view/Main/ you get some understanding about what the snippet does. We can rename to Set Caching Headers or Adjust Caching Headers or Set/Add/Adjust Cache Headers (not sure we need the -ing ending).
Set is probably simplest. I moved it to: http://extensions.xwiki.org/xwiki/bin/view/Extension/Set+Caching+Headers and added the cache tag.
Thanks! I'm going to add other options on that page: * Rendering cache * Cache macro
I hinted to that, would be better to scribe it better. paul
On Mar 15, 2011, at 1:01 PM, Paul Libbrecht wrote:
Le 15 mars 2011 à 12:33, Vincent Massol a écrit :
I would prefer Caching-Headers (or Caching+Headers or...).
Well I aligned it with the "rule" we've used for naming extensions and scripts which is: * Words separated by spaces * Mention action for scripts The idea is when you look at http://extensions.xwiki.org/xwiki/bin/view/Main/ you get some understanding about what the snippet does. We can rename to Set Caching Headers or Adjust Caching Headers or Set/Add/Adjust Cache Headers (not sure we need the -ing ending).
Set is probably simplest. I moved it to: http://extensions.xwiki.org/xwiki/bin/view/Extension/Set+Caching+Headers
and added the cache tag.
Thanks! I'm going to add other options on that page: * Rendering cache * Cache macro
I hinted to that, would be better to scribe it better.
Done Thanks -Vincent
participants (3)
-
Marius Dumitru Florea -
Paul Libbrecht -
Vincent Massol