在这里做什么?我有大量文件,Google Speed Page曾说过这些文件:“利用浏览器缓存”。但是我不知道怎么办?我是否会弄乱或更改Apache配置文件(如下),或者在.htaccess页面中放置一些内容?
<IfModule mod_proxy.c>
ProxyRequests Off
CacheRoot "/var/run/proxy"
CacheSize 1024
CacheGcInterval 24
#CacheMaxExpire 24
#CacheLastModifiedFactor 0.1
#CacheDefaultExpire 1
#NoCache a_domain.com another_domain.edu joes.garage_sale.com
<Directory "disabled_proxy">
Allow from example.com
Deny from all
Order Deny,Allow
</Directory>
</IfModule>
##
#### mod_expires is configured so that all static files but images
#### expire after 60 seconds. Any response that has a life span of more
#### than 5 seconds (see webperfcache.conf) will be cached by webperfcache.
#### Make sure your CGIs return a "Cache-Control: no-cache" header if you
#### elect to make your dynamically generated HTML pages not cache-able.
#### If all your HTML pages are static you may also increase ExpiresDefault.
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault A60
ExpiresByType image/bmp A3600
ExpiresByType image/gif A3600
ExpiresByType image/ief A3600
ExpiresByType image/jpeg A3600
ExpiresByType image/png A3600
ExpiresByType image/tiff A3600
ExpiresByType image/x-cmu-raster A3600
ExpiresByType image/x-portable-anymap A3600
ExpiresByType image/x-portable-bitmap A3600
ExpiresByType image/x-portable-graymap A3600
ExpiresByType image/x-portable-pixmap A3600
ExpiresByType image/x-rgb A3600
ExpiresByType image/x-xbitmap A3600
ExpiresByType image/x-xpixmap A3600
ExpiresByType image/x-xwindowdump A3600
ExpiresByType audio/basic A3600
ExpiresByType audio/midi A3600
ExpiresByType audio/mpeg A3600
ExpiresByType audio/x-aiff A3600
ExpiresByType audio/x-pn-realaudio A3600
ExpiresByType audio/x-pn-realaudio-plugin A3600
ExpiresByType audio/x-realaudio A3600
ExpiresByType audio/x-wav A3600
ExpiresByType video/mpeg A3600
ExpiresByType video/quicktime A3600
ExpiresByType video/x-msvideo A3600
ExpiresByType video/x-sgi-movie A3600
</IfModule>
最佳答案
几天前我在做同样的事情。将此添加到我的.htaccess文件中:
ExpiresActive On
ExpiresByType image/gif A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/png A2592000
ExpiresByType image/x-icon A2592000
ExpiresByType text/css A86400
ExpiresByType text/javascript A86400
ExpiresByType application/x-shockwave-flash A2592000
#
<FilesMatch "\.(gif¦jpe?g¦png¦ico¦css¦js¦swf)$">
Header set Cache-Control "public"
</FilesMatch>
现在,当我运行google speed page时,利用浏览器缓存不再是重中之重。
希望这可以帮助。
关于php - 利用浏览器缓存,如何在apache或.htaccess上使用?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6878427/