The Code-Bin
Dynamic Content and HTTP 304
Posted by: Stephen | December 7, 2008 @ 5:41pm

PHP Code



Syntax Highlighting





Author Comments
Say you're serving up a CSS file, but it's actually made on-the-fly by PHP, having a .php extension. How can you make sure you're not making your users re-load this file every time the page is accessed?

This script will check the current file's last-modified time against the If-Modified-Since header. If they have fresh results, a HTTP 304 status code will be sent. If they need fresh results, they'll get them.

This code will NEED to be at the very beginning of your PHP script.
Rating


4.35 / 8
245 Votes