prevent caching

Posted on 2005-04-18
Last Modified: 2013-12-25
if i open the url on the same window it returns the cahched data.
if i open in new window it works fine...

how do i prevent CGI from caching.

Question by:shahrahulb
    LVL 1

    Author Comment

    i alreaady tried

    print "<html> <head>
    <META Http-Equiv=\"Cache-Control\" Content=\"no-cache\">
    <META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">
    <META http-equiv=\"Expires\" CONTENT=\"0\">


    not working
    LVL 1

    Author Comment

    is it possible that server is caching this data?????
    LVL 18

    Expert Comment

    Hi shahrahulb,
    > is it possible that server is caching this data?????

    not very likely, unless you have a proxy server in between.
    try adding the headers to the actual http header too, instead of just the meta's.

    also, check what your browser does: install Firefox and get yourself the livehttpheaders extension. it's a life saver.

    LVL 48

    Expert Comment

    CGI scripts aren't cached as they dynamically generate their output.  However, if your webserver runs in a cluster, you may run into problems that appear to look like caching issues.
    LVL 51

    Accepted Solution

    shahrahulb suggestion is half-way correct, except that it only affects the client, but not the servers in the response chain

    You have to write propper HTTP headers to prevent caching. Unfortunatelly there're some different one, and more worse browsers doe interprete them in different ways. I'd use all following headers:

    Cache-Control : no-cache;
    Pragma : no-cache;
    Expires : -1

    for more details see:

    >  is it possible that server is caching this data
    a propper configured server should respect above HTTP headers, and for CGI it should always add automatically:

    Cache-Control : no-cache;

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
    Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
    Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now