apache_conf 使用.htaccess启用和禁用浏览器缓存

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了apache_conf 使用.htaccess启用和禁用浏览器缓存相关的知识,希望对你有一定的参考价值。

 # Enable and Disable Browser Caching with .htaccess
 
 ## Enable Examples
 
 ### 1 MONTH for static assets
 <filesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
 Header set Cache-Control "max-age=2592000, public"
 </filesMatch>
 
 ### 1 DAY for rss feeds and robots
 <filesMatch ".(xml|txt)$">
 Header set Cache-Control "max-age=86400, public, must-revalidate"
 </filesMatch>
  
 ### 4 HOURS for your real articles files
 <filesMatch ".(html|htm)$">
 Header set Cache-Control "max-age=14400, must-revalidate"
 </filesMatch>
 
 # Disable Example
 
 <filesMatch ".(html|htm|js|css|jpg|png)$">
	FileETag None
	<ifModule mod_headers.c>
		Header unset ETag
		Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
		Header set Pragma "no-cache"
		Header set Expires "Wed, 08 Jan 1975 05:00:00 GMT"
	</ifModule>
</filesMatch>

# Tips on Usage:

-- .htaccess configuration effects the directory contents in which it resides, as well as its subdirectories
-- .htaccess cannot be ready by browsers so it is secure for other operations.
-- creating the .htaccess file is best done on the server because most OS system settings will initially hide any file created that begins with a "."

以上是关于apache_conf 使用.htaccess启用和禁用浏览器缓存的主要内容,如果未能解决你的问题,请参考以下文章

apache_conf 在htaccess中启用php错误登录

apache_conf 启用GZIP压缩#optimization #gzip #htaccess

apache_conf 必须启用postname permalinksApache重写模块的基本.htaccess文件 - 主要用于YeoPress

apache_conf 通过启用gzip压缩来提高页面速度。在WordPress中添加到.htaccess

apache_conf 使用.htaccess设置密码

apache_conf 使用.htaccess强制HTTPS