Just setup a Wordpress site on an using an Amazon EC2 Bitnami AMI. I've ran the usual suspects of speed tests and have added this to my .htaccess file, like I've done dozens of times before:

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

However I still get the issues around saying I should leverage browser caching. Apache has restarted and even the server has been rebooted but same happens. I've checked the Apache2 config file and the mod_expires module is present (I'm 99% sure it is!)

Anything I'm missing that is maybe specific to Amazon EC2 and/or Bitnami Wordpress?

Standard Bitnami AMI... Linux version 3.13.0-100-generic

  • The most obvious problem to check for is whether mod_expires is installed and enabled. That is going to depend on which image you installed on your EC2 instance. Different Linux distributions have different ways of installing and configuring Apache modules. – Stephen Ostermiller Dec 6 '16 at 11:40
  • The standard Bitnami AMI... Linux version 3.13.0-100-generic. Also expires_module is enabled. – pee2pee Dec 6 '16 at 12:28

There appear to be two things you need to check.

First edit /opt/bitnami/apache2/conf/httpd.conf and make sure that the line loading mod_expires is not commented out (comments start with #). If it is, uncomment it and restart Apache. (source)

If you are trying to set the expires headers in .htaccess you will also have to allow overrides in your Apache configuration. Edit httpd.conf and make sure that allowoverride all is specified. (source)

  • This is not commented: LoadModule expires_module modules/mod_expires.so. Also allowoverride all is specified. Apache restarted. Nothing – pee2pee Dec 6 '16 at 12:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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