skip to Main Content

I have configured ETags (using ACS Commons ETag support) on my AEM server and disabled ETag on Apache. But once the file gets cached on the Dispatcher, Apache always returns 200 with response body instead of 304 Not modified. I have validated that the ETag value stored in the ".h" file and in the response is the same as the value of the "If-None-Match" header of the request.
If I remove the cached files from the dispatcher and resend the request then AEM correctly returns 304.

I have also disabled mod_deflate as I have found at some places that the deflate’s "-gzip" suffix could cause issues with ETag matching.

Also, instead of ETag, I have tried a similar thing with Last-Modified and If-Modified-Since headers. But no luck with that as well. I have noticed that we generally have Last-Modified headers in place in most cases and I have never seen 304. So, it seems like it is not a version-specific issue. I couldn’t find any configuration documentation related to this. Could someone please guide me where am I going wrong?

2

Answers


  1. Check this https://issues.apache.org/bugzilla/show_bug.cgi?id=45023

    I have enabled deflate

    RequestHeader edit "If-None-Match" "^"(.*)-gzip"$" ""$1""
    
    Header edit "ETag" "^"(.*[^g][^z][^i][^p])"$" ""$1-gzip""
    
    Login or Signup to reply.
  2. We don’t use Etags since it is diffcult to sync them across a cluster and Last Modified works fine.

    # turn off Etags completely, since they will differ across the cluster
    FileETag None
    
    # FileETag None is not enough for every server.
    Header unset ETag
    
    # instead we use Expires and Cache-Control headers
    ExpiresActive On
    
    # set Expires default to 15 minutes, so browser caches for a visit
    ExpiresDefault  "access plus 15 minutes"
    # but a maybe few types are exempt from this
    ExpiresByType text/cache-manifest   "access plus 0 seconds"
    ExpiresByType text/html "access plus 0 seconds"
    ExpiresByType text/xml  "access plus 0 seconds"
    ExpiresByType application/xml   "access plus 0 seconds"
    ExpiresByType application/json  "access plus 0 seconds"
    # set CacheControl public header
    # so content is cached in Firefox, even over https
    # "public" keyword MUST be the first value in the header, or it will not work in FF
    Header onsuccess edit Cache-Control "^(.*)$" "public, $1"
    
    

    You can adjust the timeouts accordingly, depending on your content.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search