0

Is it possible to force set HTTP 304 status for all images? I wrote code below in my vhost, but now instead 404/304 status I get 500

<filesMatch "\.(ico|gif|jpg|png|jpeg)$">
  Header set 304 "HTTP/1.0 304 Not Modified"
</filesMatch>

I have "Apache/2.2.16 (Debian)" version. Thanks for any help

Debian
  • 11
  • 1
  • What are you trying to do? A `304` status when the client has not sent the corresponding headers is going to cause broken images. – Ladadadada May 29 '14 at 21:13
  • Because I would like to restore cached images from my visitors like in this post: [link](http://diovo.com/2009/12/getting-cached-images-in-your-website-from-the-visitors/) – Debian May 29 '14 at 21:35
  • 2
    Oh wow. That's so messed up I think it might actually work. – Ladadadada May 29 '14 at 22:04

2 Answers2

2

Interesting approach. Not sure how effective it will be, but worth a shot I suppose.

That's attempting to set a response header, when you need to manipulate the response status. Try..

RewriteEngine On
RewriteRule \.(ico|gif|jpg|png|jpeg)$ - [L,R=304]
Shane Madden
  • 114,520
  • 13
  • 181
  • 251
1

Rather than Header, what you probably want here is RedirectMatch

RedirectMatch 304 "\.(ico|gif|jpg|png|jpeg)$"

The key to why this works is in the Redirect documentation:

Other status codes can be returned by giving the numeric status code as the value of status. If the status is between 300 and 399, the URL argument must be present, otherwise it must be omitted. Note that the status must be known to the Apache code (see the function send_error_response in http_protocol.c).


Good luck on getting your images back. Might I suggest investing in some backups of what you have left?

Ladadadada
  • 26,337
  • 7
  • 59
  • 90