I'm using the code below in my .htaccess file to enable caching for my website:

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"

In that code, you can see that the cache expiration time is set as 1 year for some file types and 1 month for others. What I need is to make it expire after a single day. I have already tried to replace it by "1 day" and "24 hours", but neither of those work.

  • 1
    "already tried to replace it by "1 day"" - Was that literally "1 day" or "access 1 day"? "1 day" is certainly an error as you are missing the base (ie. access or modification) - this would have resulted in a 500 error. However, "access 1 day" should work - the plus keyword is optional.
    – MrWhite
    Sep 8, 2015 at 18:07

1 Answer 1


It might be as simple as missing one keyword that is causing your issue.

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 day"
ExpiresByType image/jpeg "access plus 1 day"
ExpiresByType image/gif "access plus 1 day"
ExpiresByType image/png "access plus 1 day"
ExpiresByType text/css "access plus 1 day"
ExpiresByType application/pdf "access plus 1 day"
ExpiresByType text/x-javascript "access plus 1 day"
ExpiresByType application/x-shockwave-flash "access plus 1 day"
ExpiresByType image/x-icon "access plus 1 day"
ExpiresDefault "access plus 1 day"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.