caching - 304 Not modified response when serving files through PHP -


i have php file serving image files. looks this:

$dir = 'directory/containing/files'; $file = getfileinfofromdatabase(filter_input(input_get, 'article'));  header("content-type: $file->type; name=\"$file->filename\""); header("name: \"$file->filename\""); header("content-disposition: inline; filename=\"$file->filename\""); header("content-length: $file->size");  die(readfile($dir.'/'.$file->id)); 

an url calling file looks this: www.example.com/article/image.php?article=4. 4 id of article, sent database information stored there image file associated article.

this works well. when loading url, image , response headers looking this:

cache-control:private, max-age=10800, pre-check=10800 connection:keep-alive content-disposition:inline; filename="filename.jpg" content-length:37308 content-type:image/jpeg; name="filename.jpg" date:wed, 30 sep 2015 08:42:26 gmt keep-alive:timeout=5, max=75 last-modified:wed, 30 sep 2015 08:32:19 gmt name:"filename.jpg" server:apache 

the next time try loading url, request contains following header:

if-modified-since:wed, 30 sep 2015 08:32:19 gmt 

and 304 not modified response, fine.

however, if update database point different file, same 304 not modified response! have modify php file serving image file new version of image file.

how can solve this? have turn off caching file? or can change last-modified header of image file instead of php file in way?

if know modification time of changed file, can change last_modified header if request if-modified-since older.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -