1

I have an redirection when 404 is served with apache:

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

# other rewrite rules that cannot be affected

How can I set no-cache header only when redirection above is applied?

pwas
  • 3,225
  • 18
  • 40

1 Answers1

1

From this answer How to prevent http file caching in Apache httpd (MAMP) put the folowing code at .htaccess file :

 <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>
Mohammed Elhag
  • 4,272
  • 1
  • 10
  • 18
  • I'd like to set `no-cache` only for 302 redirection that `ErrorDocument 404 https://my404.com/image.jpg` generates; not an every image file. – pwas Feb 18 '18 at 20:23
  • this is not for every image , only for the image.jpg which you redirect all wrong requests to it – Mohammed Elhag Feb 18 '18 at 20:25
  • Ok, but includes it 302 response itself? I mean, the stub image can be cached (it is on separate domain) but 302 redirection should not be cached. – pwas Feb 18 '18 at 20:28
  • sorry, there is no 302 here it is only 404 – Mohammed Elhag Feb 18 '18 at 20:36