In httpd.conf
the last lines are:
ExpiresActive On
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
ExpiresDefault "access plus 3 days"
</FilesMatch>
When I run YSlow it says all my CSS files (and others) do not have expiration set. The CSS files are in subdirectories but I believe "\."
should match all files regardless of subdirectory.
Apache is set up for virtual hosts, but the above directives are outside of vhosts section at the very bottom of httpd.conf
.
There is a directive for LoadModule expires_module modules/mod_expires.so
in the .conf
file.
The site is on AWS running AWS Linux and Apache2. I restarted apache before checking if it worked.
In answer to your question, this works for me in my httpd.conf:
LoadModule expires_module /usr/lib/apache2/modules/mod_expires.so
ExpiresActive On
<filesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
ExpiresDefault "access plus 3 days"
</filesMatch>
Here are a few things to try:
1) Make sure mod_expires.so is where you think it is. You can see what modules are being included by using this in your terminal: apache2 -M
.
2) Make sure your directives apply to the files you're interested in (i.e. not getting overwritten by a .htaccess
file somewhere farther down the line)
3) Make sure the LoadModule
directive is in your httpd.conf file
4) In your FilesMatch
regex, you should escape the dot with a backslash otherwise you're matching any character. Not a big issue, but you'd end up applying the rule to non-static pages like "site.com/politico"
(note the ico
ending) for example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With