Reputation: 4666
<?php
chdir('../../../../');
include('bootstrap.php');
$place = isset($_GET['place']) ? (is_array($_GET['place'])) ? intval($_GET['place'][0]) : intval($_GET['place']) : null;
$query = mysql_query("SELECT `place`, `image`, `imagetype` FROM `topvideo` WHERE `place` = '" . $place . "'");
if (mysql_num_rows($query))
{
while ($row = mysql_fetch_array($query))
{
$im = imagecreatefromstring($row['image']);
if ($im !== false)
{
header('Cache-Control: public, proxy-revalidate');
header('Last-Modified:Mon, 02 Nov 2009 09:50:18 GMT');
header('Expires: ' . gmdate ("D, d M Y H:i:s", time() + 60 * 60 * 24 * 24 . ' GMT');
header('Content-Type: image/jpeg');
imagejpeg($im);
imagedestroy($im);
}
}
}
The response is always 200, but I need to cache the image for 2 days and the response was 304.... why? sorry for bad english
Upvotes: 0
Views: 413
Reputation: 53158
to send 304 You need to include Etag in your response headers, etag is something like hash of content itself and date of it's creation.
After you include etag in response the browser will send you request header "If-None-Match".
You have to compare this headers and if they match respond with 304, if not send new content with new Etag header and status 200.
Upvotes: 1