Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-2478

SetExpirationHeaders fails to disable browser caching for Firefox 3

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.6.4
    • Fix Version/s: 4.0, 3.6.4, 3.6.5
    • Component/s: cache
    • Labels:
    • Patch included:
      Yes
    • Testcase included:
      Yes

      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:

      • it tests for BrowserCachePolicyResult identity instead of using the return value of #getExpirationDate
      • it sets the Expires header twice, to two different values

      I'll attach a patch later this day.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              gjoseph Magnolia International
              Reporter:
              pmm Philippe Marschall
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Date of First Response: