I have cacheable dynamic content made in PHP 5.1.0+. I already send the correct headers (including Last-Modified and ETag) to clients.
I now want my script to be able to answer $_SERVER['HTTP_IF_MODIFIED_SINCE']
and $_SERVER['HTTP_IF_NONE_MATCH']
when present. When the conditions matches, I want to answer a HTTP 304 "Not Modified"
to clients.
What are the correct conditions? When exactly I issue a 304 instead of the whole content?
The accepted answer in question How to know when to send a 304 Not Modified response seems to issue this correctly but I have hard times to port that code to PHP 5.
Thank you!
Why?
Having done a lot of research on the subject I found that conditional requests actually slow down a site. There are certain scenarios where that is not the case, but mapping to general usage patterns overall it results in lower throughput and less effective caching.
C.
The answer you're referencing seems to contain all you need. To summarize:
I've always used:
Don't remember whether I wrote it or got it from somewhere else...
I'm normally using it at the top of a file in this way:
From - http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.5
So, if you send a 304 don't send the body.
This article will answer all your questions on caching
I found that adding
To the bottom of my htaccess file (below all rewriterule) worked.
Here is a snippet of my render_file() function.