【发布时间】:2018-02-19 04:17:25
【问题描述】:
当 404 与 apache 一起提供时,我有一个重定向:
ErrorDocument 404 https://my404.com/image.jpg
# other rewrite rules that cannot be affected
如何设置no-cache 仅在应用上述重定向时标头?
【问题讨论】:
当 404 与 apache 一起提供时,我有一个重定向:
ErrorDocument 404 https://my404.com/image.jpg
# other rewrite rules that cannot be affected
如何设置no-cache 仅在应用上述重定向时标头?
【问题讨论】:
从这个答案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>
【讨论】:
no-cache 仅用于ErrorDocument 404 https://my404.com/image.jpg 生成的302 重定向;不是每个图像文件。