I've been trying to speed up my site and various speed measuring sites have pointed out that my main priority should be to set the expires header on the served content to 'Leverage browser caching'. I thought I could do this by making use of mod_expires, but for some reason it's not working.
Also I've been advised to add 'Header append Vary: Accept-Encoding', because apparently some clients can't handle decryption (fair enough....?!). So I looked at adding that via mod_headers.
Both of those Apache modules are installed on my VPS but after testing with those page speed tools and double-checking the headers with a tool called rebot, http://redbot.org/, I can see it's not working.
What am I doing wrong?
Here's the htaccess script:
### SILVERSTRIPE START ###
<Files *.ss>
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Files>
<Files web.config>
Order deny,allow
Deny from all
</Files>
# This denies access to all yml files, since developers might include sensitive
# information in them. See the docs for work-arounds to serve some yaml files
<Files *.yml>
Order allow,deny
Deny from all
</Files>
# Define some expiry header settings.
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/html "access plus 5 minutes"
ExpiresByType image/gif "access plus 7 day"
ExpiresByType image/png "access plus 7 day"
ExpiresByType image/jpg "access plus 7 day"
ExpiresByType image/jpeg "access plus 7 day"
ExpiresByType image/ico "access plus 7 day"
ExpiresByType text/css "access plus 7 day"
ExpiresByType text/javascript "access plus 7 day"
ExpiresByType application/x-javascript "access plus 7 day"
</IfModule>
# Append the 'Vary: Accept-Encoding' for resources that might need it.
<IfModule mod_headers.c>
<FilesMatch "\.(js|css|xml|gz)$">
Header append Vary: Accept-Encoding
</FilesMatch>
</IfModule>
ErrorDocument 404 /assets/error-404.html
ErrorDocument 500 /assets/error-500.html
<IfModule mod_rewrite.c>
SetEnv HTTP_MOD_REWRITE On
RewriteEngine On
RewriteBase '/'
RewriteRule ^vendor(/|$) - [F,L,NC]
RewriteRule silverstripe-cache(/|$) - [F,L,NC]
RewriteRule composer\.(json|lock) - [F,L,NC]
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\.php$
RewriteRule .* framework/main.php?url=%1&%{QUERY_STRING} [L]
</IfModule>
### SILVERSTRIPE END ###
and here's the output from redbot:
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 09 Jan 2014 12:35:02 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Cache-Control: no-cache, max-age=0, must-revalidate, no-transform, max-
age=300
Expires: Thu, 09 Jan 2014 12:40:02 GMT
Content-Encoding: gzip
It also says 'This response is negotiated, but doesn't have an appropriate Vary header.' and critically: 'The max-age Cache-Control directive appears more than once.' - is something else inside Silverstripe or anything else setting that expiry time to 0?
tl;dr; Do I have to do anything special in SilverStripe to set an expiry time on files and/or content?
Any help, much appreciated.