Unable to enable .htaccess (Leverage Browser Caching)

Hello,

Gezzz. . . I thought I followed the steps correctly to enable .htaccess, but it's not enabling (I test it on Google PageSpeed Insights and also by uploading a changed jpg image).

If anyone has any ideas to share, it sure would be appreciated. Here are the steps I took:

1.) My .htaccess file has only the below content and is located in my document root directory with all of my website content:

EXPIRES CACHING

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 text/html "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"

EXPIRES CACHING

2.) I disabled the apache default config file and have my own that handles my website content. In my sites-available config file located at /etc/apache2/sites-available/myvirtualhost.conf I inserted my document root location after AccessFileName and in the tag, and I changed AllowOveride None to Override All below here:


.htaccess file location

AccessFileName /documentRootDirectory/.htaccess

Options Indexes FollowSymLinks MultiViews

AllowOverride All

Order allow,deny

allow from all


3.) And in my apache config file etc/apache2/apache2.conf I made no changes:


AccessFileName .htaccess

Order allow,deny

Deny from all

Satisfy all


Thank you in advance for any suggestions.

–Eric

3 Replies

Do you have "LoadModule expiresmodule modules/modexpires.so" anywhere in your config? (or whatever the Debian variation is).

Thank you Stephen for the help. I'm definitely a server-side NB here, but I'm definitely learning.

I'm using Ubuntu 12.04 rather than Debian.

And, no, I don't have have any LoadModule expires directives in my virtual host config file: /etc/apache2/sites-available/myconfig.conf which is the file that overrides my document root contents directives, but in only my .htaccess file as above.

Should I also have LoadModule expires directives in virtual host config file to enable .htaccess? If so, are there instructions on how to write them?

Much thanks for the help.

Eric

Does your phpinfo() show that modexpires is loaded? If it is, have you restarted apache after modifying your vhost file?

If not, you should probably search the web for: ubuntu apache php load mod_expires

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct