I have recently deployed a website on a VPS that supports Apache2, and was working on performance improvement suggestions by YSlow. Among those improvements were using mod_deflate and mod_expires, and since I have root access, I can directly edit the Apache config files.
mod_deflate is now working, but I am having issues with mod_expires so here is what I have done:
enable expires module and restart the server
a2enmod expires
service apache2 restart
create a new file "expires.conf" under mods_enabled that contains the following:
<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
# Default directive
ExpiresDefault "access plus 1 month"
# My favicon
ExpiresByType image/x-icon "access plus 1 year"
# Images
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
# CSS
ExpiresByType text/css "access plus 1 month"
# Javascript
ExpiresByType application/javascript "access plus 1 year"
</IfModule>
However, when checking on various browsers Dev Tools under Network, the files show a Cache Control of None.
I thought of using my mod_expires script above in a .htaccess located in the root directory of my website: /var/www/sitename/public_html, since settings in the .htaccess override any prior settings made in the apache config files.
For that, i enabled the use of htaccess in apache2.conf.
I tested that my htaccess file was indeed working by willingly introducing an error in it (commented out the IfModule open tag). Refreshing the browser gave me a 500 server error. So the htaccess file was being processed.
Unfortunately, the browser dev tools still showed no cache control, and I am running out of ideas.
Am I missing something? Thanks!