Jump to content

mikerowe81

New Members
  • Posts

    2
  • Joined

  • Last visited

mikerowe81's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Kicken, Thanks for the response. I did consider the last-modified-date, but my content isn't as conducive to that option like your blog example. I am working on a Student Information System, so most of the content will change pretty regularly, which I know kind of defeats the effectiveness of caching, but things like a course's student lists and assignment lists should solidify as a semester progresses thus increasing its effectiveness. I could see where hashing just the content I am concerned about might save some processing, but that would also mean I would need to define what content to hash on each page. The beauty of using the output buffer was I can include the same script on every page knowing that the final output would be hashed and compared just before it is sent. The other aspect of my project I probably should have mentioned was that most of the content is AJAX driven, so that allows me to separate my layout which would be cached independently of my content. Thanks again for your insights, that has helped me thing through some other aspects of this.
  2. I have been researching some strategies to optimize a web application I am working on particularly related to web browser caching and dynamic data. Since potentially the same dynamic content may be loaded multiple times in a session, I came up with the following method using PHP's output buffer and using a hash of the content as an ETag. I realize that the only thing I really save with this method is the transfer of data back to the user since the PHP script still has to completely run, but I was curious if anyone has done something similar and if there are any thoughts or concerns I should be aware of or what other methods may be better. Here is the code I am including at the top of each page: <?php function hash_buffer($content) { $buffer_hash = crc32($content); if ($_SERVER['HTTP_IF_NONE_MATCH'] == $buffer_hash) { header('HTTP/1.1 304 Not Modified'); header("ETag: $buffer_hash"); return ''; } header('Cache-Control: private, no-cache'); header("ETag: $buffer_hash"); return $content; } ob_start('hash_buffer'); ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.