Results 1 to 3 of 3

Thread: Response.expires = 0

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    343

    Question

    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

  2. #2
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    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
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  3. #3
    Fanatic Member Jerry Grant's Avatar
    Join Date
    Jul 2000
    Location
    Dorset, UK
    Posts
    810

    Exclamation

    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:
    Code:
    <%
    Response.Buffer = True
    Response.ExpiresAbsolute = Now() - 1
    Response.Expires = 0
    Response.CacheControl = "no-cache"
    %>
    Jerry Grant................tnarG yrreJ
    Website: <JG-Design></.net>
    Email: [email protected]
    Working towards a bug free world......
    (Not a Microsoft employee)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width