Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.mixmin.net!aioe.org!.POSTED!not-for-mail From: Twayne Newsgroups: comp.lang.php Subject: Re: Please evaluate my cache-control & pragma etc. code Date: Sat, 10 Aug 2013 13:21:24 -0400 Organization: Aioe.org NNTP Server Lines: 48 Message-ID: References: NNTP-Posting-Host: R4bBSAi8mp//si8W1Ge8sA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.php:10480 On 2013-08-10 4:49 AM, The Natural Philosopher wrote: > On 09/08/13 19:22, Twayne wrote: ... >> > session_start(); >> header('Cache-Control: no-cache, no-store, must-revalidate'); //HTTP/1.1 >> header('Expires: Sun, 01 Jul 2005 00:00:00 GMT'); >> header('Pragma: no-cache'); //HTTP/1.0 ... > my limited experience suggests that browser caching is more affected by > the etag. > I have been writing a framework that serves all pages /objects from a > database ( for reasons of security and control), and found that in > general browsers don't really honor cache control, but they do honor etags. > I think proxies tend to honor cxahche control more. > > The browsers tend to say 'ive got a copy, do I need a new one?' and > actually ask, using the etag. > > I found that out looking at my log files on pages with multiple images > under constant rerfreshing. The logs were full of 304 responses, but > there were always as many of those as the page had images for a given > page load. > > The code that checks the etag is here - it really does reduce server > load if you want to not resend data that's already been sent > > // check if etag matches if none match request headers > function check_etag($etag) > { > if(isset($_SERVER['HTTP_IF_NONE_MATCH']) && > strstr($_SERVER['HTTP_IF_NONE_MATCH'],$etag)) > { > header('HTTP/1.0 304 Not Modified'); > exit(); > } > } > This is a handy way to encourage browsers not to re-download static pages. > Which is precisely what I want to do, actually. I'll look into that a bit further and try it! Thanks much for the alternative. Best regards, Twayne`