FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Using the browser's Webcache
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Using the browser's Webcache [message #175070] Wed, 10 August 2011 09:50 Go to next message
Luke is currently offline  Luke
Messages: 10
Registered: June 2011
Karma: 0
Junior Member
Hi,

I'm trying to utilize the browser's Webcache with php. I have a
timestamp of the time when my site has been changed and I'm trying to
send a "304 Not Modified" if the user already has my page in his
cache. I'm using the function described on this page [1] under "Use
PHP to force a conditional GET". I also added the headers

header("Cache-Control: public");
header("Expires: Thu, 15 Apr 2012 20:00:00 GMT");
header("Pragma: cache");

but the page gets reloaded every time. These are the headers from the
server:

Status-Code:200 OK
Cache-Control:public
Connection:Keep-Alive
Date:Wed, 10 Aug 2011 08:20:44 GMT
Etag:"b393df7221a36ce8e02e96c7df308a16"
Expires:Thu, 15 Apr 2012 20:00:00 GMT
Keep-Alive:timeout=15, max=99
Last-Modified:Wed, 10 Aug 2011 07:50:04 GMT
Pragma:cache

I really can't figure out what the problem is.

Greetings from Germany
Lukas

[1] http://www.askapache.com/php/speed-up-sites-with-php-caching.html
Re: Using the browser's Webcache [message #175071 is a reply to message #175070] Wed, 10 August 2011 10:57 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 8/10/2011 5:50 AM, Luke wrote:
> Hi,
>
> I'm trying to utilize the browser's Webcache with php. I have a
> timestamp of the time when my site has been changed and I'm trying to
> send a "304 Not Modified" if the user already has my page in his
> cache. I'm using the function described on this page [1] under "Use
> PHP to force a conditional GET". I also added the headers
>
> header("Cache-Control: public");
> header("Expires: Thu, 15 Apr 2012 20:00:00 GMT");
> header("Pragma: cache");
>
> but the page gets reloaded every time. These are the headers from the
> server:
>
> Status-Code:200 OK
> Cache-Control:public
> Connection:Keep-Alive
> Date:Wed, 10 Aug 2011 08:20:44 GMT
> Etag:"b393df7221a36ce8e02e96c7df308a16"
> Expires:Thu, 15 Apr 2012 20:00:00 GMT
> Keep-Alive:timeout=15, max=99
> Last-Modified:Wed, 10 Aug 2011 07:50:04 GMT
> Pragma:cache
>
> I really can't figure out what the problem is.
>
> Greetings from Germany
> Lukas
>
> [1] http://www.askapache.com/php/speed-up-sites-with-php-caching.html

First of all, I don't see a 304 in your headers. But the bottom line is
you can't force a 304 - it's up to the browser to make a conditional
request (HTTP_IF_MODIFIED_SINCE).

But then it's generally not necessary to do it in PHP anyway - the web
server will handle it.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: Using the browser's Webcache [message #175080 is a reply to message #175071] Thu, 11 August 2011 08:54 Go to previous messageGo to next message
Luke is currently offline  Luke
Messages: 10
Registered: June 2011
Karma: 0
Junior Member
On Aug 10, 12:57 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> On 8/10/2011 5:50 AM, Luke wrote:
>
>
>
>
>
>> Hi,
>
>> I'm trying to utilize the browser's Webcache with php. I have a
>> timestamp of the time when my site has been changed and I'm trying to
>> send a "304 Not Modified" if the user already has my page in his
>> cache. I'm using the function described on this page [1] under "Use
>> PHP to force a conditional GET". I also added the headers
>
>> header("Cache-Control: public");
>> header("Expires: Thu, 15 Apr 2012 20:00:00 GMT");
>> header("Pragma: cache");
>
>> but the page gets reloaded every time. These are the headers from the
>> server:
>
>> Status-Code:200 OK
>> Cache-Control:public
>> Connection:Keep-Alive
>> Date:Wed, 10 Aug 2011 08:20:44 GMT
>> Etag:"b393df7221a36ce8e02e96c7df308a16"
>> Expires:Thu, 15 Apr 2012 20:00:00 GMT
>> Keep-Alive:timeout=15, max=99
>> Last-Modified:Wed, 10 Aug 2011 07:50:04 GMT
>> Pragma:cache
>
>> I really can't figure out what the problem is.
>
>> Greetings from Germany
>> Lukas
>
>> [1]http://www.askapache.com/php/speed-up-sites-with-php-caching.html
>
> First of all, I don't see a 304 in your headers.  But the bottom line is
> you can't force a 304 - it's up to the browser to make a conditional
> request (HTTP_IF_MODIFIED_SINCE).
>
> But then it's generally not necessary to do it in PHP anyway - the web
> server will handle it.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================

Hi Jerry,
look at the link I posted (only the section "Use
>> PHP to force a conditional GET") — I'm sending a 304 header. Anyway, the browser says it get's a status-code 200. That's what I don't get. The point why I'm sending those headers manually is because in this particular case I'm generating an image and redirect to it (with a location-header). But if the User already has that image in it's cache, I just wanna send a 304, so that there's no redirect and thus less requests.
Re: Using the browser's Webcache [message #175083 is a reply to message #175080] Thu, 11 August 2011 10:45 Go to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 8/11/2011 4:54 AM, Luke wrote:
> On Aug 10, 12:57 pm, Jerry Stuckle<jstuck...@attglobal.net> wrote:
>> On 8/10/2011 5:50 AM, Luke wrote:
>>
>>
>>
>>
>>
>>> Hi,
>>
>>> I'm trying to utilize the browser's Webcache with php. I have a
>>> timestamp of the time when my site has been changed and I'm trying to
>>> send a "304 Not Modified" if the user already has my page in his
>>> cache. I'm using the function described on this page [1] under "Use
>>> PHP to force a conditional GET". I also added the headers
>>
>>> header("Cache-Control: public");
>>> header("Expires: Thu, 15 Apr 2012 20:00:00 GMT");
>>> header("Pragma: cache");
>>
>>> but the page gets reloaded every time. These are the headers from the
>>> server:
>>
>>> Status-Code:200 OK
>>> Cache-Control:public
>>> Connection:Keep-Alive
>>> Date:Wed, 10 Aug 2011 08:20:44 GMT
>>> Etag:"b393df7221a36ce8e02e96c7df308a16"
>>> Expires:Thu, 15 Apr 2012 20:00:00 GMT
>>> Keep-Alive:timeout=15, max=99
>>> Last-Modified:Wed, 10 Aug 2011 07:50:04 GMT
>>> Pragma:cache
>>
>>> I really can't figure out what the problem is.
>>
>>> Greetings from Germany
>>> Lukas
>>
>>> [1]http://www.askapache.com/php/speed-up-sites-with-php-caching.html
>>
>> First of all, I don't see a 304 in your headers. But the bottom line is
>> you can't force a 304 - it's up to the browser to make a conditional
>> request (HTTP_IF_MODIFIED_SINCE).
>>
>> But then it's generally not necessary to do it in PHP anyway - the web
>> server will handle it.
>>
>> --
>> ==================
>> Remove the "x" from my email address
>> Jerry Stuckle
>> JDS Computer Training Corp.
>> jstuck...@attglobal.net
>> ==================
>
> Hi Jerry,
> look at the link I posted (only the section "Use
>>> PHP to force a conditional GET") — I'm sending a 304 header. Anyway, the browser says it get's a status-code 200. That's what I don't get. The point why I'm sending those headers manually is because in this particular case I'm generating an image and redirect to it (with a location-header). But if the User already has that image in it's cache, I just wanna send a 304, so that there's no redirect and thus less requests.

Hi, Luke,

Yes, I already looked at the link before I replied previously. My
comments haven't changed.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: speech recognition
Next Topic: json_decode
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Sep 20 15:45:54 GMT 2024

Total time taken to generate the page: 0.03892 seconds