ErrorDocument - 设置无缓存

时间:2018-02-18 16:29:04

标签: .htaccess apache2

当404使用apache时,我有一个重定向:

ErrorDocument 404 https://my404.com/image.jpg

# other rewrite rules that cannot be affected

如果仅在应用上述重定向时如何设置no-cache标题?

1 个答案:

答案 0 :(得分:0)

从这个回答How to prevent http file caching in Apache httpd (MAMP)将下面的代码放在.htaccess文件:

 <filesMatch "image\.jpg$">
 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, 11 Jan 1984 05:00:00 GMT"
 </ifModule>
</filesMatch>