Knowledgebase: PHP and Apache
Set Up Apache Cache Control
Posted by CTX Admin on 05 January 2015 12:30 PM

To implement cache-control with shared hosting, place the mod_expires directives in your .htaccess file.

For example, if you have scripts located in '~/public_html/javascripts/', make a new .htaccess file in that directory with the following contents:

ExpiresActive On
ExpiresDefault "access plus 1 week"


You can wrap an IfModule around that if you want:

<If Module mod_expires.c>
>ExpiresActive On
ExpiresDefault "access plus 1 week"
</IfModule>


The easiest way to check if this is actually working is with cURL. On a separate UNIX box, run

curl --dump-header headers http://www.mydomain.com/javascripts/prototype.js 

Note: on servers with out Nginx Acceleration Stack, changes to expiry headers will be ignored and overwritten by Nginx.

 

Then check the output with cat headers. If you see Cache-Control: max-age=604800 then you're set (604800 is a week in seconds).

(0 vote(s))
This article was helpful
This article was not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
Help Desk Software by Kayako fusion