Apache Configure static cache
Here static file refers to the picture JS, CSS and other files, the user to visit a site, in fact, most of the elements are pictures js, CSS, etc., these static files will be cached by the client's browser to the local computer, the purpose is not to go to the server on the next request to download, so that speed up, Improves the user experience. But these static files can not always be cached, he has some timeliness, then this is the expiration time.
The configuration is as follows:
<ifmodule mod_ Expires.c> expiresactive on expiresbytype image/gif "Access plus 1 days" ExpiresByType image/jpeg " Access plus 24 hours " ExpiresByType image/png " access Plus 24 hours " ExpiresByType text/css " now plus 2 Hour " ExpiresByType application/x-javascript " now plus 2 hours " ExpiresByType application/javascript " Now plus 2 hours " ExpiresByType application/x-shockwave-flash "Now plus 2 hours " ExpiresDefault " Now plus 0 min "</IFMODULE>
Or use the MOD_HEADRS.C module to implement
<ifmodule mod_headrs.c>
#htn. Html.txt class file cache one hours
<filesmatch "\. (html|htm|txt) $ ">
Header set Cache-control "max-age=3600"
</filesmatch>
#css, js,swf class file cache for one weeks
<filesmatch "\. (css|js|swf) $ ">
Header set Cache-control "max-age=604800"
</filesmatch>
#jpg, gif,jpeg,png,ico,flv,pdf and other files cache for one year
<filesmatch "\. (ico|gif|jpg|jpeg|png|flv|pdf) $ ">
Header set Cache-control "max-age=29030400"
</filesmatch>
</IfModule>
Description: The time unit here can be days, hours or even min, two different methods, the above is used Mod_expires, and the following is mod_headers, to use these modules, you must have been supported in advance.
How to see if support, using commands :
#/usr/local/apache2/bin/apachectl-m
This article from "12350027" blog, declined reprint!
Apache Configure static cache