Click to See Complete Forum and Search --> : Response.expires = 0
turfbult
Feb 15th, 2001, 02:42 AM
Hello,
What does <%response.expires=0%> do, and is it good programming practice to include this?? How will it affect my speed.
I read an article of the top20 tips/tricks for ASP pages and I cannot remember seeing this.
Thanks,
T
JoshT
Feb 15th, 2001, 06:52 AM
Response.Expires tells the web browser when the page expires from its cache. 0 tells the web browser that the page expires immediately - that is to get a copy from the server every time the user visits the page. Using something like response.expires = 30 tells the web browser not to re-request the page but to used the cached copy for if the user visited the page for 30 minutes, after that amount of time, request a new copy.
You can also set it to be a absolute date and time. Also, some web browser probably don't handle it.
It's up to the purpose of the web site to determine how to use it. Setting it to 0 will ensure the user gets the latest version of the page, but they will have to redownload the page each view, and that obviously slows them down and pages a higher load on your server.
Josh
Jerry Grant
Feb 15th, 2001, 06:55 AM
From MSDN:
Expires
The Expires property specifies the length of time before a page cached on a browser expires. If the user returns to the same page before it expires, the cached version is displayed.
Syntax
Response.Expires [= number]
Parameters
number
The time in minutes before the page expires.
Remarks
When your .asp file calls Response.Expires, IIS creates an HTTP header indicating the time on the server. If the system time on the client is earlier than the system time on the server (due to either the client or server having an inaccurate time setting, or time-zone differences) setting the parameter to 0 will not have the effect of expiring the page immediately. You can use the Response.ExpiresAbsolute property to achieve immediate expiration of a page. In addition, you can use a negative number for the Expires property. For example
<%Response.Expires = -1 %>
will expire the response immediately.
If there are multiple calls to Response.Expires on a single page, the server will use the shortest time period.
Therefore, if you don't want to cache any pages do something like this:
<%
Response.Buffer = True
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
%>
:cool:
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.