Reputation: 22527
I am using php on an Apache server. I am unable to set expiration headers in .htaccess on the server that I am working on, as it is a shared server and they (the web host) will not install the mod_expires module in the apache build.
I have always used the ExpiresActive On
and set the default cache expiration for images, js
, xml
and text files within the .htaccess
file.
What are my other options?
thanks.
Upvotes: 3
Views: 2984
Reputation: 41
You can do it with .htaccess and without mod_expires.
<IfModule mod_headers.c>
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Expires "Wed, 15 Apr 2020 20:00:00 GMT"
Header set Cache-Control "public"
</FilesMatch>
</IfModule>
Upvotes: 4
Reputation: 449385
Somebody might come up with an Apache specific solution that works without the module, but as a last resort, if there is no other way, you could route all your traffic through PHP and output headers there. But that would mean sending every resource through the PHP interpreter, and be horribly expensive.
Upvotes: 1