views:

116

answers:

1

I need the specialists' help.

I am trying to mix two files htaccess

The first:

<IfModule mod_mime.c>
<FilesMatch "\.html\.gz$">
ForceType text/html
FileETag None
</FilesMatch>
AddEncoding gzip .gz
AddType text/html .gz
</IfModule>
<IfModule mod_deflate.c>
SetEnvIfNoCase Request_URI \.gz$ no-gzip
</IfModule>
<IfModule mod_headers.c>
Header set Cache-Control 'max-age=300, must-revalidate'
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/html A300
</IfModule>

The second:

<FilesMatch "\.(flv|gif|jpg|jpeg|png|ico|swf)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>

<FilesMatch "\.(js|css|pdf|txt)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>

<FilesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=43200"
</FilesMatch>

The first file is used by the plugin wp-supercache (worpress)

I would like that

image files Cache-Control = 2592000  
files as css e js Cache-Control = 604800  
files htm had Cache-Control = 43200

But it would like not to lose the functionalities of the plugin and for this reason I ask for help.

Thank you very much and excuse my English

Vera

A: 

It would seem that you're missing the headers module in Apache (I assume Apache2 in the following, but syntax should be near similar). This works on my machine (without headers module loaded):

<IfModule mod_mime.c>
<FilesMatch "\.html\.gz$">
ForceType text/html
FileETag None
</FilesMatch>
AddEncoding gzip .gz
AddType text/html .gz
</IfModule>
<IfModule mod_deflate.c>
SetEnvIfNoCase Request_URI \.gz$ no-gzip
</IfModule>
<IfModule mod_headers.c>
Header set Cache-Control 'max-age=300, must-revalidate'
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/html A300
</IfModule>

<IfModule mod_headers.c>
<FilesMatch "\.(flv|gif|jpg|jpeg|png|ico|swf)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
<FilesMatch "\.(js|css|pdf|txt)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>    
<FilesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=43200"
</FilesMatch>
</IfModule>

To enable the headers module in Apache2:

a2endmod headers
apache2ctl restart
Sune Rievers
I tried to insert this at the and of file but did not work: <FilesMatch "\.(flv|gif|jpg|jpeg|png|ico|swf)$"> Header set Cache-Control "max-age=2592000" </FilesMatch> <FilesMatch "\.(js|css|pdf|txt)$"> Header set Cache-Control "max-age=604800" </FilesMatch>Vera
Vera
I've updated my post because I found it was because of missing headers module in Apache2 (at least on my installation).
Sune Rievers
SuneThank you for the answer, I was on vacation and had not read your answer. The found solution was to use mod_deflate with FilesMatch
Vera