![]() |
Caching image requests through PHP - If-Modified-Since not being sent. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Caching image requests through PHP - If-Modified-Since not being sent. (/showthread.php?tid=19988) |
Caching image requests through PHP - If-Modified-Since not being sent. - El Forum - 06-24-2009 [eluser]louis w[/eluser] Not directly code igniter but I thought I would ask this here to see if anyone can help out since I'm not getting replies elsewhere. I am serving images through php and having some problems setting it up to respond with 304 headers to save on load time. Most of the code below I found on php.net. It works, however ALWAYS responds with 200. For some reason the If-Modified-Since header is not being sent on any requests even though I am sending the Last-Modified header initially. This is being done on an apache server. Any idea what might be wrong? Code: // Get headers sent by the client. Caching image requests through PHP - If-Modified-Since not being sent. - El Forum - 09-19-2009 [eluser]Unknown[/eluser] I cannot tell you what the difference is, however the code below works for me. Tested on Debian Linux 4.0 with apache2/PHP5.2. Code: function get_binary($galleryid, $imageid, $type) /* <== "controller function" */ Caching image requests through PHP - If-Modified-Since not being sent. - El Forum - 09-20-2009 [eluser]BrianDHall[/eluser] That's some pretty nice code - thanks for posting! Caching image requests through PHP - If-Modified-Since not being sent. - El Forum - 09-21-2009 [eluser]louis w[/eluser] I forget what the problem was with my code but I did end up getting it working. I think it may have actually been a testing issue with a firewall. One addition I added is below. This will let you stream large files instead of having to read them all into memory (which will someone error). Code: $handle = fopen($load_path, "rb"); |