[MAGNOLIA-2478] SetExpirationHeaders fails to disable browser caching for Firefox 3 Created: 19/Nov/08 Updated: 23/Jan/13 Resolved: 22/Jan/09 |
|
| Status: | Closed |
| Project: | Magnolia |
| Component/s: | cache |
| Affects Version/s: | 3.6.4 |
| Fix Version/s: | 4.0, 3.6.4, 3.6.5 |
| Type: | Bug | Priority: | Minor |
| Reporter: | Philippe Marschall | Assignee: | Magnolia International |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | browser, cache | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Template: |
|
||||||||
| Patch included: |
Yes
|
||||||||
| Acceptance criteria: |
Empty
|
||||||||
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
||||||||
| Bug DoR: |
[ ]*
Steps to reproduce, expected, and actual results filled
[ ]*
Affected version filled
|
||||||||
| Testcase included: |
Yes
|
||||||||
| Date of First Response: | |||||||||
| Description |
|
If we use the BrowserCachePolicy Never Firefox 3 still caches the page for a short amount of time. If we add "no-store" value for the Cache-Control header Firefox does no longer cache the page. Our code looks like this: public void processCacheRequest(HttpServletRequest request, HttpServletResponse response, FilterChain chain, Cache cache, CachePolicyResult cachePolicyResult) throws IOException, ServletException { BrowserCachePolicy browserCachePolicy = this.getCacheConfiguration().getBrowserCachePolicy(); BrowserCachePolicyResult clientCacheResult = browserCachePolicy.canCacheOnClient(cachePolicyResult); if (clientCacheResult.getExpirationDate() < 0) { response.setHeader("Pragma", "no-cache"); response.setHeader("Cache-Control", "no-cache, no-store"); response.setDateHeader("Expires", 0L); } else { final long maxAgeSeconds = (clientCacheResult.getExpirationDate() - System.currentTimeMillis()) / 1000; response.setHeader("Pragma", ""); response.setHeader("Cache-Control", "max-age=" + maxAgeSeconds + ", public"); response.setDateHeader("Expires", clientCacheResult.getExpirationDate()); } } We haven't yet tested with other browsers. There are some other issues we have with SetExpirationHeaders:
I'll attach a patch later this day. |
| Comments |
| Comment by Philippe Marschall [ 19/Nov/08 ] |
|
patch attached |
| Comment by Philippe Marschall [ 19/Nov/08 ] |
|
patch and test added |
| Comment by Philippe Marschall [ 19/Nov/08 ] |
|
There is a similar issue in CacheHeadersFilter. Patch and fix attached. |
| Comment by Magnolia International [ 19/Nov/08 ] |
|
thanks, will apply asap ! |
| Comment by Magnolia International [ 21/Nov/08 ] |
|
Patch applied to both trunk and 3.6 branch except for the if () statement in SetExpirationHeaders - any specific reason for not using the constant ? |
| Comment by Magnolia International [ 22/Jan/09 ] |
|
Philippe, if there was any concern about using the NO_CACHE constant, please re-open, but as far as I know, as far as custom BrowserCachePolicy implementations also use it, it should be fine. |
| Comment by Matteo Pelucco [ 01/Apr/09 ] |
The same happens on IE6 / IE7. Only a CTRL + F5 (Cache-Control: no-cache on HTTP Request Headers) forces server to send fresh page. I'll attach a little docs about it. |
| Comment by Matteo Pelucco [ 01/Apr/09 ] |
|
Different HTTP Header (Req vs. Resp) regarding Cache-Control |
| Comment by Magnolia International [ 02/Apr/09 ] |
|
Pragma: no-cache capitalization fixed by |
| Comment by Matteo Pelucco [ 02/Apr/09 ] |
|
Just to better explain my pdf. Anyway, few days ago we have reintroduced server-side caching, with excellent results (from 2 / 2.5 seconds per page --> to 100 ms), flush on every minute (tested and working). Here all internal editors uses IE6. From that moment a lot of internal editors (we have more than 70) started to say: "Hey, why homepage is not up-to-date?" Only using CTRL + F5 (or emptying browser cache + restart of browser) solved that issue. I've reproduced locally the issue and implemented another version of setExpirationHeaders, taken from Magnolia 3.6.5, with these changes: if (clientCacheResult == BrowserCachePolicyResult.NO_CACHE) { // response.setHeader("Pragma", "no-cache"); // response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate, max-age=0"); // response.setDateHeader("Expires", 0L); System.out.println("NO_CACHE, no headers sent"); } else { final long maxAgeSeconds = (clientCacheResult.getExpirationDate() - System.currentTimeMillis()) / 1000L; response.setHeader("Pragma", ""); response.setHeader("Cache-Control", "max-age=" + maxAgeSeconds + ", public"); response.setDateHeader("Expires", clientCacheResult.getExpirationDate()); System.out.println("cached"); } and doing that I managed to have IE6 working well, with server-side caching enabled. But as you may know, in this project there are a lot of problems... so I've not found until now enough time to test this behaviour in dept. |
| Comment by Philippe Marschall [ 02/Apr/09 ] |
|
Matteo are you sure you don't suffer from |
| Comment by Matteo Pelucco [ 02/Apr/09 ] |
|
I can not exclude, Philippe, thanks! |
| Comment by Matteo Pelucco [ 02/Apr/09 ] |
|
Done some tests, it seems to go better on 3.6.5. Strange.. But tomorrow I will investigate better and let you know. |
| Comment by Magnolia International [ 03/Apr/09 ] |
|
Thanks for the details, Matteo. Looking forward for your further investigation details |
| Comment by Magnolia International [ 24/Apr/09 ] |
|
Any news to share, Matteo ? |