asp tutorials, asp.net tutorials, sample code, and Microsoft news from 15Seconds
Data Access  |   Troubleshooting  |   Security  |   Performance  |   ADSI  |   Upload  |   Email  |   Control Building  |   Component Building  |   Forms  |   XML  |   Web Services  |   ASP.NET  |   .NET Features  |   .NET 2.0  |   App Development  |   App Architecture  |   IIS  |   Wireless
 
Pioneering Active Server
 Power Search








Active News
15 Seconds Weekly Newsletter
• Complete Coverage
• Site Updates
• Upcoming Features

More Free Newsletters
Reference
News
Articles
Archive
Writers
Code Samples
Components
Tools
FAQ
Feedback
Books
Links
DL Archives
Community
Messageboard
List Servers
Mailing List
WebHosts
Consultants
Tech Jobs
15 Seconds
Home
Site Map
Press
Legal
Privacy Policy
internet.commerce














internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

HardwareCentral
Compare products, prices, and stores at Hardware Central!

Solving a Caching And Expiring Problem
By 15 Seconds Discussion List
Rating: 4.0 out of 5
Rate this article


  • email this article to a colleague
  • suggest an article

    Jamie Writes:

    I'm using IE5.5, and I'm trying to make the page refresh even if someone hits the back button on the browser. I'm also stuck behind MS Proxy Server.

    I've tried the following:

    
    Response.Expires=0
    Response.Expires=-1
    Response.ExpiresAbsolute=#1/1/1980#
    Response.CacheControl="Private"
    Response.CacheControl="Public"
    
    
    And just about all combinations of the above

    Is this possible? I'm looking for a solution that would work on IE4+

    Jamie Replies to Himself With:

    For some reason, I did not search MSDN before, it lead me to this:

    
    <% Response.CacheControl = "no-cache" %>
    <% Response.AddHeader "Pragma", "no-cache" %>
    <% Response.Expires = -1 %> 
    
    
    I think that should fix it.

    Eric Provides An Even Better Solution!

    The code from MSDN below will work good for IE. This works a little better in all browsers...

    
    <%
    Response.ExpiresAbsolute = #1/1/1980#
    Response.AddHeader "cache-control", "no-store, must-revalidate, private" 
    Response.AddHeader "Pragma", "no-cache"
    %>
    
    
    One other consideration. If you want the page to automatically refresh when they hit BACK, the page that is in the history also must not have been created as a result of a POST operation. Otherwise the user will receive an error before it reposts the information. Therefore, you should try not to use POST on the previous page for any pages you want the user to be able to move back to.
    
    Page 1 (GET Method) ==> Page 2 (not cached) ==> Page 3 
    
    
    When the user hits the back button on page 3, page 2 will automatically be called from the server, (assuming the user has not configured his or her browser to always cache pages.)
    
    Page 1 (POST method) ==> Page 2 (not cached) ==> Page 3 
    
    
    When the user presses the back button on page 3 the user will receive an error that the previous page resulted in a POST operation. The message will prompt them to REPOST the information from page 1.

    Work around:

    
    Page 1 (post back to page 1 then redirect to page 2) ==> Page 2 (not cached)
    ==> Page 3 
    
    
    When the user presses back here, it acts the same as using the GET method above. The disadvantage is that it requires two trips between page 1 and page 2.

    A Stumped Gregory Enquires Further:

    Eric,

    I understand everything until the last part (your workaround)

    
    Page 1 (post back to page 1 then redirect to page 2) ==> Page 2 (not
    cached)
    ==> Page 3
    
    
    Forgive me for being a little confused but how would I do that? I have pages with this very scenario and I'd like to implement this alternative. Can you give a few lines of code? I guess I don't understand "post back to page 1 then redirect to page 2". I appreciate any help you could give :)

    Now an Expert, Jamie Clarifies:

    I think he means have your post's action argument post right to the same page.

    Then, during your handling of the post method, redirect to page 2.

    Then, if they hit the back button, they would just go back to page 1, the post method wouldn't be called again (the page would just get refreshed).

    This conversation string was taken from the 15Seconds ASP Listserv on 2/1/01. If you have an ASP-related question or would like to share some of your knowledge with others, you may join the list by clicking here.

  • Rate This Article
    Not HelpfulMost Helpful
    1 2 3 4 5
    Supporting Products/Tools
    CustomError 2.0 for IIS
    When errors occur on a Web site, they should be handled in a way that helps the user to get back on track. Unfortunately, setting up customized error pages in IIS usually requires something many Web developers lack -- access to and familiarity with the Web server's administrative interface. With CustomError for IIS, developers can add error pages, coded by hand or created in their favorite editor, by simply uploading them to a designated directory. No administrator intervention is required.
    [Top]
    Other Articles
    Sep 22, 2004 - Unit Test - Testing with NUnit Framework
    Kamran Qamar introduces unit testing with NUnit and offers some best practices, tips, and tricks.
    [Read This Article]  [Top]
    Aug 10, 2004 - Implementing and Promoting Daily Builds
    Automatic daily builds is a well known software engineering best practice. This article introduces a strategy for implementing and promoting daily builds and offers tips and tricks for preventing and fixing breaks.
    [Read This Article]  [Top]
    Jun 21, 2004 - Using Open Source .NET Tools for Sophisticated Builds
    Building an application can be more than pressing F5. With an increasing number of quality packages being released, developers for the .NET platform now have options to create a very sophisticated build process. Aaron Junod describes a sample build environment and shows how a number of tools can work together to make reliable, predictable, and value-added builds.
    [Read This Article]  [Top]
    Jun 18, 2003 - Online Database Functions Testing Tool
    This short article provides source code for a classic ASP online database functions testing application and shows how to configure and use the tool for either SQL Server or Oracle.
    [Read This Article]  [Top]
    Jan 2, 2003 - Web Application Error Handling in ASP.NET
    One of many improvements ASP.NET brings to the development table is in error handling. Adam Tuliper whips up a simple ASP.NET solution for handling those pesky and unexpected post-production errors.
    [Read This Article]  [Top]
    Sep 10, 2002 - Tracing in .NET and Implementing Your Own Trace Listeners
    Mansoor Ahmed Siddiqui explains debugging and tracing and shows how to create custom trace listeners to help ensure hassle-free development.
    [Read This Article]  [Top]
    Sep 5, 2001 - Firing Events in a Shared Hosting Environment
    Firing events on a Web server is an easy task. However most of the easy solutions require you to have your own dedicated IIS or SQL Server on the Internet to play with, a privilege not shared by many. In this article, Matthew Muller shows you how to get the same functionality in a shared hosting environment.
    [Read This Article]  [Top]
    May 25, 2001 - Avoiding a Type Mismatch Error When Using ByRef with ASP and COM
    Unlike programming inside a complete VB system, when using ByRef with ASP and COM, a complication arises because ASP's VBScript is not typed, but the component's VB is typed. This article will briefly explain how ByRef can be used with ASP and COM.
    [Read This Article]  [Top]
    Apr 18, 2001 - Error Reporting - IIS 5.0
    The script in Mark Newlands' article this week handles how errors are displayed and logged. It can capture all values in use at the time (e.g. form, querystring, session,and application level) and records them if you set a Boolean value to do so - displays custom HTML if required. Sends email, logs to database, and/or text file.
    [Read This Article]  [Top]
    Mar 12, 2001 - Transact-SQL Improves Database Error-Handling
    Transact-SQL provides developers with several database error-handling methods. Use these functions to efficiently handle database errors and add an extra level of data validation. This article discusses the @@ERROR, SP_ADDMESSAGE, and RAISERROR functions and provides examples on how to implement them.
    [Read This Article]  [Top]
    Mailing List
    Want to receive email when the next article is published? Just Click Here to sign up.

    Support the Active Server Industry



    JupiterOnlineMedia

    internet.comearthweb.comDevx.commediabistro.comGraphics.com

    Search:

    Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

    Jupitermedia Corporate Info


    Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

    Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

    Solutions
    Whitepapers and eBooks
    IBM eBook: Planning a Service Oriented Architecture
    IBM eBook: Choosing the Right Architecture--What It Means for You and Your Business
    Microsoft Article: Will Hyper-V Make VMware This Decade's Netscape?
    Avaya Article: Using Intelligent Presence to Create Smarter Business Applications
    Intel Go Parallel Article: Getting Started with TBB on Windows
    Microsoft Article: 7.0, Microsoft's Lucky Version?
    Avaya Article: How to Feed Data into the Avaya Event Processor
    IBM Article: Developing a Software Policy for Your Organization
    Microsoft Article: Managing Virtual Machines with Microsoft System Center
    Intel Go Parallel Article: Intel Threading Tools and OpenMP
    HP eBook: Storage Networking , Part 1
    Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
    MORE WHITEPAPERS, EBOOKS, AND ARTICLES
    Webcasts
    HP Video: StorageWorks EVA4400 and Oracle
    HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
    Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
    MORE WEBCASTS, PODCASTS, AND VIDEOS
    Downloads and eKits
    Red Gate Download: SQL Toolbelt and free High-Performance SQL Code eBook
    Iron Speed Designer Application Generator
    MORE DOWNLOADS, EKITS, AND FREE TRIALS
    Tutorials and Demos
    Silverlight 2 App and Walkthrough: Leverage Silverlight 2 with SQL Server and XML
    IBM Article: Enterprise Search--Do You Know What's Out There?
    HP Demo: StorageWorks EVA4400
    Microsoft Article: The Progress and Promise of Deep Zoom
    Microsoft How-to Article: Get Going with Silverlight and Windows Live
    MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES