Report this

What is the reason for this report?

How to setup expire headers on Apache?

Posted on May 30, 2015

Hi!

I used like 3 different WP plugins but none of them worked so far… so I guess I’ll have to do it manually on my server

I haven’t found any tutorial though so that’s why I’m asking you where and how can I setup expire headers for css, png, jpg,… basically everything (as long as it’s useful)

Thanks :)



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Try something like this (note: this needs the mod_expires module. Enable it with “a2enmod expires” if you’re using Ubuntu or Debian - afterwards restart Apache):

    ExpiresActive on
    ExpiresDefault "access plus 30 seconds"
    ExpiresByType text/html "access plus 15 days"
    ExpiresByType image/gif "access plus 1 months"
    ExpiresByType image/jpg "access plus 1 months"
    ExpiresByType image/jpeg "access plus 1 months"
    ExpiresByType image/png "access plus 1 months"
    ExpiresByType text/js "access plus 1 months"
    ExpiresByType text/javascript "access plus 1 months"
</IfModule>```

I hope it works for you :). Please let me know if it works!

The issue is resolved (I don’t have httpd.conf but apache2.conf!) it just didn’t have the right permission…

Thank you!

Thank you :)

Before doing anything, can you confirm that I have to put these lines in .htaccess and not in a VirtualHost configuration?

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.