Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #10471 > unrolled thread
| Started by | Twayne <nobody@spamcop.net> |
|---|---|
| First post | 2013-08-09 14:22 -0400 |
| Last post | 2013-08-10 13:17 -0400 |
| Articles | 7 — 4 participants |
Back to article view | Back to comp.lang.php
Please evaluate my cache-control & pragma etc. code Twayne <nobody@spamcop.net> - 2013-08-09 14:22 -0400
Re: Please evaluate my cache-control & pragma etc. code "J.O. Aho" <user@example.net> - 2013-08-09 22:57 +0200
Re: Please evaluate my cache-control & pragma etc. code Twayne <nobody@spamcop.net> - 2013-08-09 19:12 -0400
Re: Please evaluate my cache-control & pragma etc. code The Natural Philosopher <tnp@invalid.invalid> - 2013-08-10 09:49 +0100
Re: Please evaluate my cache-control & pragma etc. code Twayne <nobody@spamcop.net> - 2013-08-10 13:21 -0400
Re: Please evaluate my cache-control & pragma etc. code Fiver <numeralfive@gmail.com> - 2013-08-10 17:19 +0200
Re: Please evaluate my cache-control & pragma etc. code Twayne <nobody@spamcop.net> - 2013-08-10 13:17 -0400
| From | Twayne <nobody@spamcop.net> |
|---|---|
| Date | 2013-08-09 14:22 -0400 |
| Subject | Please evaluate my cache-control & pragma etc. code |
| Message-ID | <ku3c1n$vc7$1@speranza.aioe.org> |
Mainly I'm interested in whether it's considered workable/usable.
It doesn't seem to be working on my win 7 XAMPP PHP5.3 Local Server.
The data still seems to exist if/when I "go back" to the preceding page
of an e-mail form.
<?php
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
TIA,
Twayne`
[toc] | [next] | [standalone]
| From | "J.O. Aho" <user@example.net> |
|---|---|
| Date | 2013-08-09 22:57 +0200 |
| Message-ID | <b6l3enFrrc2U1@mid.individual.net> |
| In reply to | #10471 |
On 09/08/13 20:22, Twayne wrote: > Mainly I'm interested in whether it's considered workable/usable. > It doesn't seem to be working on my win 7 XAMPP PHP5.3 Local Server. > The data still seems to exist if/when I "go back" to the preceding page > of an e-mail form. It's all up to the client if it will follow cache rules from the server or not. -- //Aho
[toc] | [prev] | [next] | [standalone]
| From | Twayne <nobody@spamcop.net> |
|---|---|
| Date | 2013-08-09 19:12 -0400 |
| Message-ID | <ku3t1i$br5$1@speranza.aioe.org> |
| In reply to | #10472 |
On 2013-08-09 4:57 PM, J.O. Aho wrote: > On 09/08/13 20:22, Twayne wrote: >> Mainly I'm interested in whether it's considered workable/usable. >> It doesn't seem to be working on my win 7 XAMPP PHP5.3 Local Server. >> The data still seems to exist if/when I "go back" to the preceding page >> of an e-mail form. > > It's all up to the client if it will follow cache rules from the server > or not. > > Thanks, that's a good point! Magically, for whatever reason, it started working again after a Cold Boot; Windows in all its glory, I guess. :( Cheers,
[toc] | [prev] | [next] | [standalone]
| From | The Natural Philosopher <tnp@invalid.invalid> |
|---|---|
| Date | 2013-08-10 09:49 +0100 |
| Message-ID | <ku4uro$e53$1@news.albasani.net> |
| In reply to | #10471 |
On 09/08/13 19:22, Twayne wrote:
> Mainly I'm interested in whether it's considered workable/usable.
> It doesn't seem to be working on my win 7 XAMPP PHP5.3 Local
> Server. The data still seems to exist if/when I "go back" to the
> preceding page of an e-mail form.
>
> <?php
> 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
>
> TIA,
>
> Twayne`
>
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.
--
Ineptocracy
(in-ep-toc’-ra-cy) – a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
[toc] | [prev] | [next] | [standalone]
| From | Twayne <nobody@spamcop.net> |
|---|---|
| Date | 2013-08-10 13:21 -0400 |
| Message-ID | <ku5sql$565$1@speranza.aioe.org> |
| In reply to | #10475 |
On 2013-08-10 4:49 AM, The Natural Philosopher wrote:
> On 09/08/13 19:22, Twayne wrote:
...
>> <?php
>> 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`
[toc] | [prev] | [next] | [standalone]
| From | Fiver <numeralfive@gmail.com> |
|---|---|
| Date | 2013-08-10 17:19 +0200 |
| Message-ID | <ku5lli$aa7$1@dont-email.me> |
| In reply to | #10471 |
On 2013-08-09 20:22, Twayne wrote:
> header('Expires: Sun, 01 Jul 2005 00:00:00 GMT');
2005-07-01 was a Friday, not a Sunday.
5er
[toc] | [prev] | [next] | [standalone]
| From | Twayne <nobody@spamcop.net> |
|---|---|
| Date | 2013-08-10 13:17 -0400 |
| Message-ID | <ku5siu$4dp$1@speranza.aioe.org> |
| In reply to | #10478 |
On 2013-08-10 11:19 AM, Fiver wrote:
> On 2013-08-09 20:22, Twayne wrote:
>> header('Expires: Sun, 01 Jul 2005 00:00:00 GMT')
;
>
> 2005-07-01 was a Friday, not a Sunday.
>
> 5er
>
Hmm, good catch: Does it really matter I wonder? Maybe that explains why
it did/didn't and then did appear to work in testing.
Thanks & Regards,
Twayne`
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web