473,320 Members | 1,802 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Cache the previous page?

I have a routine that displays 60 items (with thumbnails) per page.
You can click any item and displays a new page with item details. When
the user back pages it runs the query again to display all the items.
Is there a way to cache that page and images so that second query
doesn't execute?

I do offer a pop-up window using Java but is not the default and not
used by many. I'd really like to get rid of that second query. ;)

TIA
Jul 17 '05 #1
21 2628
Nel
"Bill H" <maylar69@hot----.com> wrote in message
news:fu********************************@4ax.com...
I have a routine that displays 60 items (with thumbnails) per page.
You can click any item and displays a new page with item details. When
the user back pages it runs the query again to display all the items.
Is there a way to cache that page and images so that second query
doesn't execute?

I do offer a pop-up window using Java but is not the default and not
used by many. I'd really like to get rid of that second query. ;)

TIA


Why would you want to do that? Am I missing something here?

The thumbnails should all be cached by the browser anyway.

Nel.
Jul 17 '05 #2
Some cache options are under the control of the web browser and therefore
set by the user. In Internet Explorer, for example, under Tools->Internet
Options->Settings under the heading "check for newer versions of stored
pages" there are 4 choices:
- Every visit to the page
- Every time you start Internet Explorer
- Automatically
- Never

If you try to override the user's settings they might not be happy.

--
Tony Marston

http://www.tonymarston.net

"Bill H" <maylar69@hot----.com> wrote in message
news:fu********************************@4ax.com...
I have a routine that displays 60 items (with thumbnails) per page.
You can click any item and displays a new page with item details. When
the user back pages it runs the query again to display all the items.
Is there a way to cache that page and images so that second query
doesn't execute?

I do offer a pop-up window using Java but is not the default and not
used by many. I'd really like to get rid of that second query. ;)

TIA

Jul 17 '05 #3
On Fri, 13 Aug 2004 14:36:07 +0100, "Nel" <ne***@ne14.co.NOSPAMuk>
wrote:
"Bill H" <maylar69@hot----.com> wrote in message
news:fu********************************@4ax.com.. .
I have a routine that displays 60 items (with thumbnails) per page.
You can click any item and displays a new page with item details. When
the user back pages it runs the query again to display all the items.
Is there a way to cache that page and images so that second query
doesn't execute?

I do offer a pop-up window using Java but is not the default and not
used by many. I'd really like to get rid of that second query. ;)

TIA


Why would you want to do that? Am I missing something here?

The thumbnails should all be cached by the browser anyway.

Nel.


Yes, I realize the images are cached - I'm more interested in not
doing the query then I am the bandwidth. It's a large query that hits
a lot of rows and running it again on a simple back page simple seems
a waste.
Jul 17 '05 #4
On Fri, 13 Aug 2004 15:57:38 +0100, "Tony Marston"
<to**@NOSPAM.demon.co.uk> wrote:
Some cache options are under the control of the web browser and therefore
set by the user. In Internet Explorer, for example, under Tools->Internet
Options->Settings under the heading "check for newer versions of stored
pages" there are 4 choices:
- Every visit to the page
- Every time you start Internet Explorer
- Automatically
- Never

If you try to override the user's settings they might not be happy.


Understood, but I might like to give it a try on this one page... I'm
not sure how to override one page with "never." Maybe this would be
better asked in the HTML group. (in fact, I have an HTML book in this
pile somewhere) ;)

Thanks for the thought Tony! :)

Jul 17 '05 #5
Bill H wrote:
I have a routine that displays 60 items (with thumbnails) per page.
You can click any item and displays a new page with item details. When
the user back pages it runs the query again to display all the items.
Is there a way to cache that page and images so that second query
doesn't execute?

I do offer a pop-up window using Java but is not the default and not
used by many. I'd really like to get rid of that second query. ;)

TIA


Bill,

You could use a cookie to determine if the visitor has already seen the
page, then have your php act accordingly.

Why are you using Java for a pop-up window? That seems like overkill;
JavaScript would make more sense.

C.J.
Jul 17 '05 #6
On Fri, 13 Aug 2004 17:10:07 GMT, "C.J. Garibay"
<cj.garibay@_REMOVE_THIS_comcast.net> wrote:
Bill H wrote:
I have a routine that displays 60 items (with thumbnails) per page.
You can click any item and displays a new page with item details. When
the user back pages it runs the query again to display all the items.
Is there a way to cache that page and images so that second query
doesn't execute?

I do offer a pop-up window using Java but is not the default and not
used by many. I'd really like to get rid of that second query. ;)

TIA


Bill,

You could use a cookie to determine if the visitor has already seen the
page, then have your php act accordingly.

Why are you using Java for a pop-up window? That seems like overkill;
JavaScript would make more sense.

C.J.


So sorry, I meant JS.

That sounds like a good approach I'm simply not clear on the "how to."
I fairly now to creating apps for the Internet (yes, it shows ;)). How
would one Google this? I don't mean to be stupid but.... ;) :)

Jul 17 '05 #7
In message <fu********************************@4ax.com>, Bill H
<maylar69@hot----.com> writes
I have a routine that displays 60 items (with thumbnails) per page.
You can click any item and displays a new page with item details. When
the user back pages it runs the query again to display all the items.
Is there a way to cache that page and images so that second query
doesn't execute?


In cases like this, I store an array of the resultant ids in the
session, then run you just need to run a much easier query to pull out
the data for a page redisplay.
--
Rob...
Jul 17 '05 #8
Bill H wrote:
On Fri, 13 Aug 2004 17:10:07 GMT, "C.J. Garibay"
<cj.garibay@_REMOVE_THIS_comcast.net> wrote:

Bill H wrote:

I have a routine that displays 60 items (with thumbnails) per page.
You can click any item and displays a new page with item details. When
the user back pages it runs the query again to display all the items.
Is there a way to cache that page and images so that second query
doesn't execute?

I do offer a pop-up window using Java but is not the default and not
used by many. I'd really like to get rid of that second query. ;)

TIA


Bill,

You could use a cookie to determine if the visitor has already seen the
page, then have your php act accordingly.

Why are you using Java for a pop-up window? That seems like overkill;
JavaScript would make more sense.

C.J.

So sorry, I meant JS.

That sounds like a good approach I'm simply not clear on the "how to."
I fairly now to creating apps for the Internet (yes, it shows ;)). How
would one Google this? I don't mean to be stupid but.... ;) :)


If you're fairly new to creating web apps, this may take a little work
on your part. Your best bet is to read through the relevant parts of
the online PHP documentation (which is excellent and has user
contributed examples), and then Google anything in the documentation you
don't understand.

Main PHP documentation:
http://www.php.net/manual/en/index.php

PHP cookies function:
http://www.php.net/manual/en/function.setcookie.php

PHP sessions:
http://www.php.net/manual/en/ref.session.php

As far as the "how to" is concerned, what you're doing is referred to as
keeping track of the user's state. There are generally two ways to do
this -- cookies, or sessions. Cookies may be the easier way to go for a
beginner.

When the visitor first visits your page, your PHP script should check
for the presence of a cookie that's associated with that page. If the
user _doesn't_ have a cookie, then the PHP script runs it's query,
decides what images to send for that page and also sends a cookie with
the location of those images. If the user _does_ have a cookie for that
page, then the PHP script just sends the images that are listed in the
cookie instead of running another query.

C.J.
Jul 17 '05 #9
On Fri, 13 Aug 2004 19:36:01 GMT, "C.J. Garibay"
<cj.garibay@_REMOVE_THIS_comcast.net> wrote:
Bill H wrote:
On Fri, 13 Aug 2004 17:10:07 GMT, "C.J. Garibay"
<cj.garibay@_REMOVE_THIS_comcast.net> wrote:

Bill H wrote:
I have a routine that displays 60 items (with thumbnails) per page.
You can click any item and displays a new page with item details. When
the user back pages it runs the query again to display all the items.
Is there a way to cache that page and images so that second query
doesn't execute?

I do offer a pop-up window using Java but is not the default and not
used by many. I'd really like to get rid of that second query. ;)

TIA

Bill,

You could use a cookie to determine if the visitor has already seen the
page, then have your php act accordingly.

Why are you using Java for a pop-up window? That seems like overkill;
JavaScript would make more sense.

C.J.

So sorry, I meant JS.

That sounds like a good approach I'm simply not clear on the "how to."
I fairly now to creating apps for the Internet (yes, it shows ;)). How
would one Google this? I don't mean to be stupid but.... ;) :)


If you're fairly new to creating web apps, this may take a little work
on your part. Your best bet is to read through the relevant parts of
the online PHP documentation (which is excellent and has user
contributed examples), and then Google anything in the documentation you
don't understand.

Main PHP documentation:
http://www.php.net/manual/en/index.php

PHP cookies function:
http://www.php.net/manual/en/function.setcookie.php

PHP sessions:
http://www.php.net/manual/en/ref.session.php

As far as the "how to" is concerned, what you're doing is referred to as
keeping track of the user's state. There are generally two ways to do
this -- cookies, or sessions. Cookies may be the easier way to go for a
beginner.

When the visitor first visits your page, your PHP script should check
for the presence of a cookie that's associated with that page. If the
user _doesn't_ have a cookie, then the PHP script runs it's query,
decides what images to send for that page and also sends a cookie with
the location of those images. If the user _does_ have a cookie for that
page, then the PHP script just sends the images that are listed in the
cookie instead of running another query.

C.J.


Thanks so much for the reply. I know sessions and cookies, where I'm
at a bit of a loss is the mechanics of sending the user back to a
cached page instead of executing the query.

Wouldn't 'referer' or JS "back page" be good in-so-much as I only want
to address a back page not if they have visited the page. If they hit
the "show units" button I want a new query to run.

It's this only back page to a cached page that I'm a little at a loss
about - did any of that make sense? ;) :)

Jul 17 '05 #10
On Fri, 13 Aug 2004 19:56:30 GMT, Bill H <maylar69@hot----.com> wrote:
On Fri, 13 Aug 2004 19:36:01 GMT, "C.J. Garibay"
<cj.garibay@_REMOVE_THIS_comcast.net> wrote:
Bill H wrote:
On Fri, 13 Aug 2004 17:10:07 GMT, "C.J. Garibay"
<cj.garibay@_REMOVE_THIS_comcast.net> wrote:
Bill H wrote:
>I have a routine that displays 60 items (with thumbnails) per page.
>You can click any item and displays a new page with item details. When
>the user back pages it runs the query again to display all the items.
>Is there a way to cache that page and images so that second query
>doesn't execute?
>
>I do offer a pop-up window using Java but is not the default and not
>used by many. I'd really like to get rid of that second query. ;)
>
>TIA

Bill,

You could use a cookie to determine if the visitor has already seen the
page, then have your php act accordingly.

Why are you using Java for a pop-up window? That seems like overkill;
JavaScript would make more sense.

C.J.
So sorry, I meant JS.

That sounds like a good approach I'm simply not clear on the "how to."
I fairly now to creating apps for the Internet (yes, it shows ;)). How
would one Google this? I don't mean to be stupid but.... ;) :)


If you're fairly new to creating web apps, this may take a little work
on your part. Your best bet is to read through the relevant parts of
the online PHP documentation (which is excellent and has user
contributed examples), and then Google anything in the documentation you
don't understand.

Main PHP documentation:
http://www.php.net/manual/en/index.php

PHP cookies function:
http://www.php.net/manual/en/function.setcookie.php

PHP sessions:
http://www.php.net/manual/en/ref.session.php

As far as the "how to" is concerned, what you're doing is referred to as
keeping track of the user's state. There are generally two ways to do
this -- cookies, or sessions. Cookies may be the easier way to go for a
beginner.

When the visitor first visits your page, your PHP script should check
for the presence of a cookie that's associated with that page. If the
user _doesn't_ have a cookie, then the PHP script runs it's query,
decides what images to send for that page and also sends a cookie with
the location of those images. If the user _does_ have a cookie for that
page, then the PHP script just sends the images that are listed in the
cookie instead of running another query.

C.J.


Thanks so much for the reply. I know sessions and cookies, where I'm
at a bit of a loss is the mechanics of sending the user back to a
cached page instead of executing the query.

Wouldn't 'referer' or JS "back page" be good in-so-much as I only want
to address a back page not if they have visited the page. If they hit
the "show units" button I want a new query to run.

It's this only back page to a cached page that I'm a little at a loss
about - did any of that make sense? ;) :)


hmmm I see holes in my approach here... if a user hits "back page" on
a specfic page is there a way to temporary overide browser settings
and not refresh?

So I come in the top run the query, drop a cookie that says "kilroy
was here" and then overide the browser setting on the next pass if the
cookie is present. Now the how to overide part, should I ask that in
HTML group? Maybe I have enough of a clue now to Google. :)

Jul 17 '05 #11
Bill H wrote:
On Fri, 13 Aug 2004 19:56:30 GMT, Bill H <maylar69@hot----.com> wrote:

On Fri, 13 Aug 2004 19:36:01 GMT, "C.J. Garibay"
<cj.garibay@_REMOVE_THIS_comcast.net> wrote:

Bill H wrote:
On Fri, 13 Aug 2004 17:10:07 GMT, "C.J. Garibay"
<cj.garibay@_REMOVE_THIS_comcast.net> wrote:

>Bill H wrote:
>
>
>
>>I have a routine that displays 60 items (with thumbnails) per page.
>>You can click any item and displays a new page with item details. When
>>the user back pages it runs the query again to display all the items.
>>Is there a way to cache that page and images so that second query
>>doesn't execute?
>>
>>I do offer a pop-up window using Java but is not the default and not
>>used by many. I'd really like to get rid of that second query. ;)
>>
>>TIA
>
>Bill,
>
>You could use a cookie to determine if the visitor has already seen the
>page, then have your php act accordingly.
>
>Why are you using Java for a pop-up window? That seems like overkill;
>JavaScript would make more sense.
>
>C.J.
So sorry, I meant JS.

That sounds like a good approach I'm simply not clear on the "how to."
I fairly now to creating apps for the Internet (yes, it shows ;)). How
would one Google this? I don't mean to be stupid but.... ;) :)
If you're fairly new to creating web apps, this may take a little work
on your part. Your best bet is to read through the relevant parts of
the online PHP documentation (which is excellent and has user
contributed examples), and then Google anything in the documentation you
don't understand.

Main PHP documentation:
http://www.php.net/manual/en/index.php

PHP cookies function:
http://www.php.net/manual/en/function.setcookie.php

PHP sessions:
http://www.php.net/manual/en/ref.session.php

As far as the "how to" is concerned, what you're doing is referred to as
keeping track of the user's state. There are generally two ways to do
this -- cookies, or sessions. Cookies may be the easier way to go for a
beginner.

When the visitor first visits your page, your PHP script should check
for the presence of a cookie that's associated with that page. If the
user _doesn't_ have a cookie, then the PHP script runs it's query,
decides what images to send for that page and also sends a cookie with
the location of those images. If the user _does_ have a cookie for that
page, then the PHP script just sends the images that are listed in the
cookie instead of running another query.

C.J.


Thanks so much for the reply. I know sessions and cookies, where I'm
at a bit of a loss is the mechanics of sending the user back to a
cached page instead of executing the query.

Wouldn't 'referer' or JS "back page" be good in-so-much as I only want
to address a back page not if they have visited the page. If they hit
the "show units" button I want a new query to run.

It's this only back page to a cached page that I'm a little at a loss
about - did any of that make sense? ;) :)

hmmm I see holes in my approach here... if a user hits "back page" on
a specfic page is there a way to temporary overide browser settings
and not refresh?

So I come in the top run the query, drop a cookie that says "kilroy
was here" and then overide the browser setting on the next pass if the
cookie is present. Now the how to overide part, should I ask that in
HTML group? Maybe I have enough of a clue now to Google. :)


Bill,

Unfortunately, you can't override the browser's settings. When a user
hits the back button on his browser, it will either display the content
from the local cache or send a GET request to the URI to check if the
page has changed since it was last cached locally (depending on how the
browser's cache settings are set).

The only thing you have control over in this situation is your server.
So if your server is hit with another GET request, your only recourse is
to check the visitor's state to see if he's already requested the URI in
question.

There _may_ be a way to override a browser's cache settings using
JavaScript (emphasis on may), but I doubt it. At any rate, PHP is
definitely unable to affect a browser's cache settings.

You can check with an HTML newsgroup or JavaScript newsgroup (or even an
IE and/or Mozilla newsgroup), but I'm pretty sure you can not manipulate
a visitor's browser's cache settings.

C.J.
Jul 17 '05 #12
On Fri, 13 Aug 2004 21:22:04 GMT, "C.J. Garibay"
<cj.garibay@_REMOVE_THIS_comcast.net> wrote:
Bill H wrote:
On Fri, 13 Aug 2004 19:56:30 GMT, Bill H <maylar69@hot----.com> wrote:

On Fri, 13 Aug 2004 19:36:01 GMT, "C.J. Garibay"
<cj.garibay@_REMOVE_THIS_comcast.net> wrote:
Bill H wrote:
>On Fri, 13 Aug 2004 17:10:07 GMT, "C.J. Garibay"
><cj.garibay@_REMOVE_THIS_comcast.net> wrote:
>
>
>
>>Bill H wrote:
>>
>>
>>
>>>I have a routine that displays 60 items (with thumbnails) per page.
>>>You can click any item and displays a new page with item details. When
>>>the user back pages it runs the query again to display all the items.
>>>Is there a way to cache that page and images so that second query
>>>doesn't execute?
>>>
>>>I do offer a pop-up window using Java but is not the default and not
>>>used by many. I'd really like to get rid of that second query. ;)
>>>
>>>TIA
>>
>>Bill,
>>
>>You could use a cookie to determine if the visitor has already seen the
>>page, then have your php act accordingly.
>>
>>Why are you using Java for a pop-up window? That seems like overkill;
>>JavaScript would make more sense.
>>
>>C.J.
>
>
>So sorry, I meant JS.
>
>That sounds like a good approach I'm simply not clear on the "how to."
>I fairly now to creating apps for the Internet (yes, it shows ;)). How
>would one Google this? I don't mean to be stupid but.... ;) :)
>

If you're fairly new to creating web apps, this may take a little work
on your part. Your best bet is to read through the relevant parts of
the online PHP documentation (which is excellent and has user
contributed examples), and then Google anything in the documentation you
don't understand.

Main PHP documentation:
http://www.php.net/manual/en/index.php

PHP cookies function:
http://www.php.net/manual/en/function.setcookie.php

PHP sessions:
http://www.php.net/manual/en/ref.session.php

As far as the "how to" is concerned, what you're doing is referred to as
keeping track of the user's state. There are generally two ways to do
this -- cookies, or sessions. Cookies may be the easier way to go for a
beginner.

When the visitor first visits your page, your PHP script should check
for the presence of a cookie that's associated with that page. If the
user _doesn't_ have a cookie, then the PHP script runs it's query,
decides what images to send for that page and also sends a cookie with
the location of those images. If the user _does_ have a cookie for that
page, then the PHP script just sends the images that are listed in the
cookie instead of running another query.

C.J.

Thanks so much for the reply. I know sessions and cookies, where I'm
at a bit of a loss is the mechanics of sending the user back to a
cached page instead of executing the query.

Wouldn't 'referer' or JS "back page" be good in-so-much as I only want
to address a back page not if they have visited the page. If they hit
the "show units" button I want a new query to run.

It's this only back page to a cached page that I'm a little at a loss
about - did any of that make sense? ;) :)

hmmm I see holes in my approach here... if a user hits "back page" on
a specfic page is there a way to temporary overide browser settings
and not refresh?

So I come in the top run the query, drop a cookie that says "kilroy
was here" and then overide the browser setting on the next pass if the
cookie is present. Now the how to overide part, should I ask that in
HTML group? Maybe I have enough of a clue now to Google. :)


Bill,

Unfortunately, you can't override the browser's settings. When a user
hits the back button on his browser, it will either display the content
from the local cache or send a GET request to the URI to check if the
page has changed since it was last cached locally (depending on how the
browser's cache settings are set).

The only thing you have control over in this situation is your server.
So if your server is hit with another GET request, your only recourse is
to check the visitor's state to see if he's already requested the URI in
question.

There _may_ be a way to override a browser's cache settings using
JavaScript (emphasis on may), but I doubt it. At any rate, PHP is
definitely unable to affect a browser's cache settings.

You can check with an HTML newsgroup or JavaScript newsgroup (or even an
IE and/or Mozilla newsgroup), but I'm pretty sure you can not manipulate
a visitor's browser's cache settings.

C.J.


Roger that C.J.

Actually Rob Allen offered a smart solution that I have to believe
would have dawned on me at some point. ;) That is to save the result
ID's of the query to an array and simply use those when the user
returns... thanks Rob! :)

Jul 17 '05 #13
On Fri, 13 Aug 2004 19:32:44 +0100, Rob Allen <ro***@the-allens.net>
wrote:
In message <fu********************************@4ax.com>, Bill H
<maylar69@hot----.com> writes
I have a routine that displays 60 items (with thumbnails) per page.
You can click any item and displays a new page with item details. When
the user back pages it runs the query again to display all the items.
Is there a way to cache that page and images so that second query
doesn't execute?


In cases like this, I store an array of the resultant ids in the
session, then run you just need to run a much easier query to pull out
the data for a page redisplay.


Thanks Rob!

As I said in another post on this topic I have to believe this would
have dawned on me at some point! ;) :)

Thank you,
Bill

Jul 17 '05 #14
Bill H wrote:
I have a routine that displays 60 items (with thumbnails) per page.
You can click any item and displays a new page with item details.
When the user back pages it runs the query again to display all the
items. Is there a way to cache that page and images so that second
query doesn't execute?


Of course, using standard http cache headers. The simplest method for
images is to store them as static files, and let your server do the
work. Be sure to configure the server to set explicit freshness info for
maximum caching. For the page that displays the thumbs and data, you can
use cache-control headers.

<?php
header("Cache-Control: max-age=600"); // 10 minutes
?>

The time should take into account how often you update the data on which
the query is based. If it's only once per week, then increase the
cache-control max-age value to a couple of hours. NB: Headers *must* be
sent **before** any data is sent.
<?php
header("Cache-Control: max-age=7200"); // 2 hours
?>

This may accomplish what you want without further fuss. If you want to
do more, then consider determining when you last modified the data, and
send a Last-Modified header. Then, when there's a request for the
thumbnails page, process the request headers, looking for
If-Modified-Since. If the user's copy is still fresh, send "304 Not
Modified" and exit the script.

I've done all this -- and for sevearal pages with thumbnails, as well
for individual photo pages and a catalogue -- for a photography site:

http://www.julietremblay.com/

The cache-control stuff is dead easy. The Last-Modified stuff is a
little dicey, but if you're serious, then give it a try. Feel free to
ask me if you run into trouble. I have links plus my own code to offer.

HTH

--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/
Jul 17 '05 #15
C.J. Garibay wrote:
I'm pretty sure you can not manipulate a visitor's browser's
cache settings.


Correct, you cannot manipulate such settings.

--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/
Jul 17 '05 #16
Bill H wrote:
I know sessions and cookies, where I'm at a bit of a loss is the
mechanics of sending the user back to a cached page instead of
executing the query.
You don't need sessions, nor cookies, to encourage caching. In fact,
they are likely to *prevent* caching. See my other response for how to
encourage caching by user-agents (and proxies).
Wouldn't 'referer' or JS "back page" be good in-so-much as I only
want to address a back page not if they have visited the page.
No. KISS (keep it simple, stupid!). :-) Use what's already available.
If they hit the "show units" button I want a new query to run.


I'm afraid I don't know what this button does. You'll need to provide a
url if I need to see this part to help you.

--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/
Jul 17 '05 #17
Bill H wrote:
On Fri, 13 Aug 2004 21:22:04 GMT, "C.J. Garibay"
<cj.garibay@_REMOVE_THIS_comcast.net> wrote:

Bill H wrote:

On Fri, 13 Aug 2004 19:56:30 GMT, Bill H <maylar69@hot----.com> wrote:

On Fri, 13 Aug 2004 19:36:01 GMT, "C.J. Garibay"
<cj.garibay@_REMOVE_THIS_comcast.net> wrote:

>Bill H wrote:
>
>
>
>>On Fri, 13 Aug 2004 17:10:07 GMT, "C.J. Garibay"
>><cj.garibay@_REMOVE_THIS_comcast.net> wrote:
>>
>>
>>
>>
>>>Bill H wrote:
>>>
>>>
>>>
>>>
>>>>I have a routine that displays 60 items (with thumbnails) per page.
>>>>You can click any item and displays a new page with item details. When
>>>>the user back pages it runs the query again to display all the items.
>>>>Is there a way to cache that page and images so that second query
>>>>doesn't execute?
>>>>
>>>>I do offer a pop-up window using Java but is not the default and not
>>>>used by many. I'd really like to get rid of that second query. ;)
>>>>
>>>>TIA
>>>
>>>Bill,
>>>
>>>You could use a cookie to determine if the visitor has already seen the
>>>page, then have your php act accordingly.
>>>
>>>Why are you using Java for a pop-up window? That seems like overkill;
>>>JavaScript would make more sense.
>>>
>>>C.J.
>>
>>
>>So sorry, I meant JS.
>>
>>That sounds like a good approach I'm simply not clear on the "how to."
>>I fairly now to creating apps for the Internet (yes, it shows ;)). How
>>would one Google this? I don't mean to be stupid but.... ;) :)
>>
>
>If you're fairly new to creating web apps, this may take a little work
>on your part. Your best bet is to read through the relevant parts of
>the online PHP documentation (which is excellent and has user
>contributed examples), and then Google anything in the documentation you
>don't understand.
>
>Main PHP documentation:
>http://www.php.net/manual/en/index.php
>
>PHP cookies function:
>http://www.php.net/manual/en/function.setcookie.php
>
>PHP sessions:
>http://www.php.net/manual/en/ref.session.php
>
>As far as the "how to" is concerned, what you're doing is referred to as
>keeping track of the user's state. There are generally two ways to do
>this -- cookies, or sessions. Cookies may be the easier way to go for a
>beginner.
>
>When the visitor first visits your page, your PHP script should check
>for the presence of a cookie that's associated with that page. If the
>user _doesn't_ have a cookie, then the PHP script runs it's query,
>decides what images to send for that page and also sends a cookie with
>the location of those images. If the user _does_ have a cookie for that
>page, then the PHP script just sends the images that are listed in the
>cookie instead of running another query.
>
>C.J.

Thanks so much for the reply. I know sessions and cookies, where I'm
at a bit of a loss is the mechanics of sending the user back to a
cached page instead of executing the query.

Wouldn't 'referer' or JS "back page" be good in-so-much as I only want
to address a back page not if they have visited the page. If they hit
the "show units" button I want a new query to run.

It's this only back page to a cached page that I'm a little at a loss
about - did any of that make sense? ;) :)
hmmm I see holes in my approach here... if a user hits "back page" on
a specfic page is there a way to temporary overide browser settings
and not refresh?

So I come in the top run the query, drop a cookie that says "kilroy
was here" and then overide the browser setting on the next pass if the
cookie is present. Now the how to overide part, should I ask that in
HTML group? Maybe I have enough of a clue now to Google. :)


Bill,

Unfortunately, you can't override the browser's settings. When a user
hits the back button on his browser, it will either display the content

from the local cache or send a GET request to the URI to check if the

page has changed since it was last cached locally (depending on how the
browser's cache settings are set).

The only thing you have control over in this situation is your server.
So if your server is hit with another GET request, your only recourse is
to check the visitor's state to see if he's already requested the URI in
question.

There _may_ be a way to override a browser's cache settings using
JavaScript (emphasis on may), but I doubt it. At any rate, PHP is
definitely unable to affect a browser's cache settings.

You can check with an HTML newsgroup or JavaScript newsgroup (or even an
IE and/or Mozilla newsgroup), but I'm pretty sure you can not manipulate
a visitor's browser's cache settings.

C.J.

Roger that C.J.

Actually Rob Allen offered a smart solution that I have to believe
would have dawned on me at some point. ;) That is to save the result
ID's of the query to an array and simply use those when the user
returns... thanks Rob! :)


Well, that's what I was trying to suggest when I said:

"If the user _doesn't_ have a cookie, then the PHP script runs it's
query, decides what images to send for that page and also sends a cookie
with he location of those images."

C.J.
Jul 17 '05 #18
On Fri, 13 Aug 2004 22:57:16 GMT, "C.J. Garibay"
<cj.garibay@_REMOVE_THIS_comcast.net> wrote:
Bill H wrote:
On Fri, 13 Aug 2004 21:22:04 GMT, "C.J. Garibay"
<cj.garibay@_REMOVE_THIS_comcast.net> wrote:

Bill H wrote:
On Fri, 13 Aug 2004 19:56:30 GMT, Bill H <maylar69@hot----.com> wrote:

>On Fri, 13 Aug 2004 19:36:01 GMT, "C.J. Garibay"
><cj.garibay@_REMOVE_THIS_comcast.net> wrote:
>
>
>
>>Bill H wrote:
>>
>>
>>
>>>On Fri, 13 Aug 2004 17:10:07 GMT, "C.J. Garibay"
>>><cj.garibay@_REMOVE_THIS_comcast.net> wrote:
>>>
>>>
>>>
>>>
>>>>Bill H wrote:
>>>>
>>>>
>>>>
>>>>
>>>>>I have a routine that displays 60 items (with thumbnails) per page.
>>>>>You can click any item and displays a new page with item details. When
>>>>>the user back pages it runs the query again to display all the items.
>>>>>Is there a way to cache that page and images so that second query
>>>>>doesn't execute?
>>>>>
>>>>>I do offer a pop-up window using Java but is not the default and not
>>>>>used by many. I'd really like to get rid of that second query. ;)
>>>>>
>>>>>TIA
>>>>
>>>>Bill,
>>>>
>>>>You could use a cookie to determine if the visitor has already seen the
>>>>page, then have your php act accordingly.
>>>>
>>>>Why are you using Java for a pop-up window? That seems like overkill;
>>>>JavaScript would make more sense.
>>>>
>>>>C.J.
>>>
>>>
>>>So sorry, I meant JS.
>>>
>>>That sounds like a good approach I'm simply not clear on the "how to."
>>>I fairly now to creating apps for the Internet (yes, it shows ;)). How
>>>would one Google this? I don't mean to be stupid but.... ;) :)
>>>
>>
>>If you're fairly new to creating web apps, this may take a little work
>>on your part. Your best bet is to read through the relevant parts of
>>the online PHP documentation (which is excellent and has user
>>contributed examples), and then Google anything in the documentation you
>>don't understand.
>>
>>Main PHP documentation:
>>http://www.php.net/manual/en/index.php
>>
>>PHP cookies function:
>>http://www.php.net/manual/en/function.setcookie.php
>>
>>PHP sessions:
>>http://www.php.net/manual/en/ref.session.php
>>
>>As far as the "how to" is concerned, what you're doing is referred to as
>>keeping track of the user's state. There are generally two ways to do
>>this -- cookies, or sessions. Cookies may be the easier way to go for a
>>beginner.
>>
>>When the visitor first visits your page, your PHP script should check
>>for the presence of a cookie that's associated with that page. If the
>>user _doesn't_ have a cookie, then the PHP script runs it's query,
>>decides what images to send for that page and also sends a cookie with
>>the location of those images. If the user _does_ have a cookie for that
>>page, then the PHP script just sends the images that are listed in the
>>cookie instead of running another query.
>>
>>C.J.
>
>Thanks so much for the reply. I know sessions and cookies, where I'm
>at a bit of a loss is the mechanics of sending the user back to a
>cached page instead of executing the query.
>
>Wouldn't 'referer' or JS "back page" be good in-so-much as I only want
>to address a back page not if they have visited the page. If they hit
>the "show units" button I want a new query to run.
>
>It's this only back page to a cached page that I'm a little at a loss
>about - did any of that make sense? ;) :)
hmmm I see holes in my approach here... if a user hits "back page" on
a specfic page is there a way to temporary overide browser settings
and not refresh?

So I come in the top run the query, drop a cookie that says "kilroy
was here" and then overide the browser setting on the next pass if the
cookie is present. Now the how to overide part, should I ask that in
HTML group? Maybe I have enough of a clue now to Google. :)
Bill,

Unfortunately, you can't override the browser's settings. When a user
hits the back button on his browser, it will either display the content

from the local cache or send a GET request to the URI to check if the

page has changed since it was last cached locally (depending on how the
browser's cache settings are set).

The only thing you have control over in this situation is your server.
So if your server is hit with another GET request, your only recourse is
to check the visitor's state to see if he's already requested the URI in
question.

There _may_ be a way to override a browser's cache settings using
JavaScript (emphasis on may), but I doubt it. At any rate, PHP is
definitely unable to affect a browser's cache settings.

You can check with an HTML newsgroup or JavaScript newsgroup (or even an
IE and/or Mozilla newsgroup), but I'm pretty sure you can not manipulate
a visitor's browser's cache settings.

C.J.

Roger that C.J.

Actually Rob Allen offered a smart solution that I have to believe
would have dawned on me at some point. ;) That is to save the result
ID's of the query to an array and simply use those when the user
returns... thanks Rob! :)


Well, that's what I was trying to suggest when I said:

"If the user _doesn't_ have a cookie, then the PHP script runs it's
query, decides what images to send for that page and also sends a cookie
with he location of those images."

C.J.


lol! Sorry, it was never about the images really so it just didn't
click... I see it now. Rob spoke the language I was thinking in is
all. But I certainly thank you for offering a solution was was too dim
to see! :)

Brian is saying that I can do what I'm asking for with headers alone
with would be the easiet of course. Think I'll grab a book and bring
myself up to speed in terms of the headers.

You've all be great! and I thank all of you!

Jul 17 '05 #19
Bill H wrote:
Brian is saying that I can do what I'm asking for with headers alone
with would be the easiet of course. Think I'll grab a book and bring
myself up to speed in terms of the headers.


Or just go online. An excellent tutorial on caches and headers:

http://www.mnot.net/cache_docs/

--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/
Jul 17 '05 #20
On Fri, 13 Aug 2004 17:57:54 -0400, Brian
<us*****@julietremblay.com.invalid> wrote:
Bill H wrote:
I have a routine that displays 60 items (with thumbnails) per page.
You can click any item and displays a new page with item details.
When the user back pages it runs the query again to display all the
items. Is there a way to cache that page and images so that second
query doesn't execute?


Of course, using standard http cache headers. The simplest method for
images is to store them as static files, and let your server do the
work. Be sure to configure the server to set explicit freshness info for
maximum caching. For the page that displays the thumbs and data, you can
use cache-control headers.

<?php
header("Cache-Control: max-age=600"); // 10 minutes
?>

The time should take into account how often you update the data on which
the query is based. If it's only once per week, then increase the
cache-control max-age value to a couple of hours. NB: Headers *must* be
sent **before** any data is sent.
<?php
header("Cache-Control: max-age=7200"); // 2 hours
?>

This may accomplish what you want without further fuss. If you want to
do more, then consider determining when you last modified the data, and
send a Last-Modified header. Then, when there's a request for the
thumbnails page, process the request headers, looking for
If-Modified-Since. If the user's copy is still fresh, send "304 Not
Modified" and exit the script.

I've done all this -- and for sevearal pages with thumbnails, as well
for individual photo pages and a catalogue -- for a photography site:

http://www.julietremblay.com/

The cache-control stuff is dead easy. The Last-Modified stuff is a
little dicey, but if you're serious, then give it a try. Feel free to
ask me if you run into trouble. I have links plus my own code to offer.

HTH


This was too easy, thanks Brian! It gives me just the behavior I was
looking for.

Cheers,
Bill
Jul 17 '05 #21
Bill H wrote:
Brian wrote:
The cache-control stuff is dead easy. The Last-Modified stuff
is a little dicey,
This was too easy,


Cache-control, I assume you mean. If you think parsing
If-Modified-Since is "too easy" then you're a better coder
than I!
It gives me just the behavior I was looking for.


Great! I only wish other authors were as observant and conscientious
about caching. Too many php driven sites ignore it completely, wasting
bandwidth and making their sites quite a bit slower.

--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/
Jul 17 '05 #22

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Bite My Bubbles | last post by:
I found the answer! It is a IIS 6 /ASP problem http://support.microsoft.com/default.aspx?scid=kb;en-us;332075
9
by: Just D. | last post by:
All, Did anybody see this strange effect? The web application is written in C#, ASP.NET, SQL, T-SQL, etc. A pretty usual stuff, complicated enough, but works fine until... Here is a question....
1
by: Ryan | last post by:
The real reason for my previous post about intercepting Application_EndRequest (from outside of Global.asax) is because of a need to create a "non persistent page level cache". I can't seem to...
0
by: NWx | last post by:
Hi, I discovered a strange (?!?!) issue related objects saved to cache. Let's explain my situation. I have a webform for user registration. Users enter username, password and other info...
14
by: Tom.PesterDELETETHISSS | last post by:
Hi, I think this question requires an in depth understanding of how a browser cache works. I hope I can reach an expert here. I may have found a quirk in the asp.net documentation or I don't...
1
by: Steve Franks | last post by:
I'm having a difficult time trying to do some basic caching of a string using VS.NET 2005 Beta 2. Here's the simple snippet I'm using in a method within my ASP.NET code behind page. if (Cache...
2
by: Just D. | last post by:
All, Can we enable/disable the cache for each control separately or it's a global feature for the whole page? I'm aware of many settings and some bugs regarding cache but I've never seen...
11
by: EagleRed | last post by:
I am writing an ASP.NET 2.0 application that uses master pages. I have some pages that must not be cached on the client. In ASP.NET 1.1 I achieved this using metatags: <meta...
5
by: Stan SR | last post by:
Hi, Some newbie questions.. :-) First, what is the namespace to use for the Cache class ? When I use this bit of code I get an error if (Cache==null) Cache.Insert("myUserList",userlist);...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.