1

I'm having a problem with mod_expires. I simply set have a default expires of 1 days and then I set the expires by type (for images and audio).

So for example i set ExpiresByType image/jpeg "access plus 1 months". The problem is that every page has the correct Expires DateTime so it has expires plus 1 days but images and audio (image/jpeg, image/png, audio/mpeg) have an expires of 12 hours. This is my configuration:

<IfModule mod_cache_disk.c>  
CacheRoot /var/cache/apache2/mod_cache_disk  
 CacheDirLevels 2  
CacheDirLength 1
</IfModule>


....
    CacheQuickHandler off

    CacheLock on
    CacheLockPath /tmp/mod_cache-lock
    CacheLockMaxAge 5

    CacheIgnoreHeaders Set-Cookie
    <Location />
        CacheEnable disk
        CacheHeader on

        CacheDefaultExpire 600
        CacheMaxExpire 86400
        CacheLastModifiedFactor 0.5

        ExpiresActive on
        ExpiresDefault "access plus 1 days"
        ExpiresByType image/jpeg "access plus 1 months"
        ExpiresByType image/png "access plus 1 months"
        ExpiresByType audio/mpeg "access plus 1 months"
        Header merge Cache-Control public
        FileETag All
    </Location>
....

I then try to add another Location and do not use ExpiresByType but still without success. This is what I try:

<LocationMatch "(.png|.mp3|.jpg|.jpeg)">
         ExpiresActive on
         Header Set Cache-Control "max-age=1678400"
         ExpiresDefault "access plus 1 days"
         FileETag All
</LocationMatch>

The Cache-Control header has the correct max-age but the expires date is still to 12 hours.

I then try to set it manually so I try something like:

Header Set Expires "Thu, 1 Jan 2020 00:00:00 GMT"

And well that's working but I need to set it to 1 months/years from the last access.

Apache only do a proxypass to a gunicorn web server that actually serve the current application.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.