6

I would like to have Apache HTTPD return response code 200 with data of resource request via a GET instead of returning response code 304 with no data. Any one have an idea how to do that?

Thanks in advance

Rafael
  • 1,061
  • 4
  • 16
  • 32
  • I am unable to achieve the opposite of this exactly. For all cached content (cached on the Apache server with header files having ETag) the server is returning 200 even though all the headers are in place correctly. (I have disabled the mod_deflate module as well). Any idea why this could happen? Any configuration changes which you have done to enable this 304 response? – ankur_rajput Mar 20 '21 at 19:00

4 Answers4

9

remove the header, add the following into the httpd.conf file

<FilesMatch "\.(filetype1|filetype2)$">
    RequestHeader unset If-Modified-Since
    RequestHeader unset If-None-Match
</FilesMatch>
Rajashekhar
  • 91
  • 1
  • 2
3

Add the following directive to your apache config file

RequestHeader unset If-Modified-Since

This will ignore IF-Modified-Since header sent from client so you will get not 304 Not Modified response.

Leonid Vysochyn
  • 1,254
  • 1
  • 7
  • 12
0

Don't send it any cache-related headers (If-Modified-Since, If-None-Match and friends) when making the request. This informs the server that the client doesn't cache, and makes it always return data.

Matti Virkkunen
  • 63,558
  • 9
  • 127
  • 159
  • Matti, unfortunately i don't have control over what's asking/requesting the resource. I was hoping there be a way to have apache just return the resource no matter if there were caching headers. – Rafael Sep 20 '10 at 15:05
  • @rafael: Why is the client caching the request in the first place if you don't want it, then? How about sending some cache-control headers to tell it not to cache your content. – Matti Virkkunen Sep 20 '10 at 15:07
  • I have no control over the client's caching. Using cache-control headers does not work. Is there a way to tell apache to ignore the If-Modified-Since header not matter the resource is? – Rafael Sep 20 '10 at 15:43
  • @rafael: I'm hesitant about giving you instructions that will break your webserver... – Matti Virkkunen Sep 20 '10 at 15:46
  • that's really nice of you. I hear and understand your concern. maybe i should of noted, what I am working on is on a dev env. Nothing i will have is in prod. in my dev env i just need to have apache ignore caching by client. – Rafael Sep 20 '10 at 16:05
-1

I'm not sure I fully understand your question. I assume you want the provide a normal HTTP answer if the client uses a correct URL, and a default page (with status 200) when the client uses a non-existing URL.

If this is the case, it can be achieved like that:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*+ /dummy.html

The first line is a condition that the URL doesn't macht an existing file on the web server. If that condidition holds, the second line is executed which serves a dummy page to the client.

Codo
  • 75,595
  • 17
  • 168
  • 206
  • It's not about providing default answer for non-existing URL's. It's about ignoring If-Modified-Since and returing answer as if resource has changed. – Jarek Przygódzki Jun 14 '11 at 10:58