Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Caching in ASP 3.0

Status
Not open for further replies.

jasonsalas

IS-IT--Management
Jun 20, 2001
480
GU
Hi everyone,

This is a 2-part question:

(1) If I implement the following line at the top of an ASP page that uses a databse connection, will the page necessarily be cached?

<% Response.Expires = 5 %>

(2) Also, if I include the same Response.Cache statement for a database-driven ASP page that has information in the query string to extract a specific record from a database, will the page itself be cached, or is this a moot point, becaise every value in the query string represents a new and unique &quot;page&quot;?



Thanks much!
 
1)The 5 specifies a cache time of 5 minutes. If you extend it further than the specific address will be cached for the longer period of time. If you wish to do a no-cache than you can set the Response.Expires = -1, in otherwords the page expires one minute ago.
2)You are correct, since each address is unique due to the querystring, it is reloaded from scratch each time rather than cached. The only way to be sure it will load the cached version is to pass it the exactly same variables/value sets in the same order in the querystring.
This is often used by people as a poor mans no-cache, by generating a random number and assigning it to a dummy variable in the querystring.

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
For my next trick I will pull a hat out of a rabbit (if you think thats bad you should see how the pigeon feels...) :p
 
Thanks for the feedback...for some reason, it's not registering (in me, mentally, that is).

I'm using this script:

<% @ Language = VBScript %>
<% Response.Expires = 1 %>

<html><body>
This is the time on the server: <%= Now() %>
</body></html>

...and for some reason, it doesn't seem to be caching. I use ASP.NET a lot now, and it's caching facilities are out of this world, and I'm trying to write something for my ASP 3 pages that will provide similar functionality, so a requesting user doesn't have to go all the way back to the database each time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top