skip to Main Content

I am facing an issue with an Apache Server. For all the requests of static files such as images or css, it is always added the following response header: Cache-Control: private, max-age=0, must-revalidate, so the file is never cached by the explorer.

It is also added the header: Cache-Control: max-age=2592000, public This header is added because of the configuration I have with the expires module,but I can not manage to avoid the other header being set. I don’t understand why the header Cache-Control: private, max-age=0, must-revalidate is set.

I have tried to avoid the header being set using Header unset Cache-Control, but always the header “private, max-age=0, must-revalidate” is set. I have tried to set the header manually (not using the expires module) using Header set Cache-Control “max-age=2592000, public”, and it works but the other header is always set. I have searched in every apache configuration file trying to determine in which part that header is set, but I couldn’t find any place or code that sets that header.

enable client caching of static content

<IfModule mod_expires.c>
 ExpiresActive On
  ExpiresByType image/gif "access plus 27 days"
  ExpiresByType image/jpeg "access plus 27 days"
  ExpiresByType image/png "access plus 27 days"
  ExpiresByType text/css "access plus 27 days"
  ExpiresByType text/javascript "access plus 27 days"
  ExpiresByType application/javascript "access plus 27 days"
  ExpiresByType application/x-javascript "access plus 27 days"
</IfModule>

<ifModule mod_headers.c> 
    # One month for image and video files
    <filesMatch ".(flv|gif|ico|jpg|jpeg|mp4|mpeg|png|svg|swf|webp)$">
        Header unset Cache-Control
        Header set Cache-Control "max-age=2592000, public"
    </filesMatch>

    # One month for JavaScript and PDF files
    <filesMatch ".(js)$">
        Header unset Cache-Control
        Header set Cache-Control "max-age=2592000, public"
    </filesMatch>

    # One month for CSS files
    <filesMatch ".(css)$">
        Header unset Cache-Control
        Header set Cache-Control "max-age=2592000, public"
    </filesMatch>
</ifModule>

The response is always like this:

HTTP/1.1 200 OK
Date: Fri, 16 Aug 2019 02:49:11 GMT
Server: Apache
Cache-Control: private, max-age=0, must-revalidate
Last-Modified: Sat, 04 May 2013 12:52:00 GMT
ETag: "108a-4dbe3eef5fc00-gzip"
Accept-Ranges: bytes
Cache-Control: max-age=2592000, public
Expires: Sun, 18 Aug 2019 02:49:11 GMT
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 4221
Keep-Alive: timeout=5, max=96
Connection: Keep-Alive
Content-Type: image/gif

2

Answers


  1. Chosen as BEST ANSWER

    I decided to start from a new fresh installation of Apache and to replicate all the configuration I had until the error was reproduced, and the problem was with a Mellon directive. I use Mellon to authenticate against ADFS, so I had this directive:

    MellonEnable "info"
    

    Once I commented out that sentence, everything worked fine.


  2. The header hasn’t been set by the expires module at the point where this configuration is applied, so your Header unset Cache-Control line doesn’t do anything.

    Instead, just turn off the expires module in these sections. That is, replace this:

    Header unset Cache-Control
    

    With this:

    <IfModule mod_expires.c>
      ExpiresActive Off
    </IfModule>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search