Advertisement
MLWALK3R

Cache

Apr 18th, 2012
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. <?php
  2. $cachetime = 3600;
  3. if (isset($headers['If-Modified-Since']) && (strtotime($headers['If-Modified-Since']) > (time()-3600)))
  4. {
  5. // Client's cache IS current, so we just respond '304 Not Modified'.
  6. header('Last-Modified: '.gmdate('D, d M Y H:i:s', (strtotime($headers['If-Modified-Since']))).' GMT', true, 304);
  7. exit();
  8. }
  9. header('Last-Modified: '.gmdate('D, d M Y H:i:s', (time()-$cachetime)).' GMT', true, 200);
  10. ob_start();
  11. ?>
  12. [/pre]
  13.  
  14. Place this at the end.
  15. [pre]
  16. <?php
  17. SendLength();
  18. function SendLength()
  19. {
  20. if(ob_get_length())
  21. {
  22. header("Content-Length: ".ob_get_length());
  23. ob_end_flush();
  24. die;
  25. }
  26. }
  27. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement