/    Sign up×
Community /Pin to ProfileBookmark

Sending a 304

Hi,

I’ve just set up a server cache for a db driven site I’m working on where the pages won’t change very often, I’d really like to send a 304 rather than the cached page when I can but I’m having trouble finding out what the script should be responding to – it doesn’t seem to be a HEAD request but some sort of GET. What field should I be testing for? Ideas and links gratefuly received,

thanks ?

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@RedAndyauthorFeb 18.2005 — Found some useful resources at webmasterworld. It's done using a conditional get.
[code=php]$req_date=(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']))?
$_SERVER['HTTP_IF_MODIFIED_SINCE']
:"";;
if ($req_date == $myCache->lastModified) {
header('HTTP/1.0 304 Not Modified');
exit;
}[/code]


not pretty but it seems to work. If anyone has an improvement please post ?
×

Success!

Help @RedAndy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...