server header and cache

Posted on 2005-04-20
Last Modified: 2010-03-04
i m printing the headers using the following script:

 require LWP::UserAgent;

my $ua = LWP::UserAgent->new;

my $response = $ua->get('');

print $response->status_line, "\n";
for( qw(Date Server Cache-Control Expires Last-Modified Etag Content-Length) ){
    print "$_: ",$response->header($_),"\n";
print "Content-Type: ",($response->header("content-type"))[0],"\n";

i get the output

200 OK Date: Wed, 20 Apr 2005 16:27:27 GMT
Server: Web Server/1.3.28 (Unix) mod_ssl/2.8.15 OpenSSL/0.9.7c mod_gzip/ mod_security/1.6 mod_jk/1.2.5 ApacheJServ/1.1.2
Last-Modified: Sat, 16 Apr 2005 08:09:03 GMT
Etag: "f05478-98-4260c81f"
Content-Length: 152
Content-Type: text/html

the cache-control and expires are empty.....
will the apache webserver still cache the data on the clients browser.  i gues it is because when i refresh the url it reads from cache.
how do i set that in apache httpd.conf
Question by:shahrahulb
    LVL 19

    Accepted Solution

    first of all you should understand that apache webserver doesn't cache data. It sends headers to browser and browser should decide should it take data from cache or take it from site.
    In apache you can use mod_expires and mod_header to set required headers that say to browser to do not cache returned html.

    Example config lines:
    Header set Expires "Sat, 16 Apr 2000 08:09:03 GMT"
    Header set Pragma no-cache
    Header set Cache-Control "no-cache no-store"

    first line sets Expires header to date which is already bypassed.
    second set Pragma header for browsers which support HTTP/1.0 protocol
    third line set Cache-Control header for browsers that support HTTP/1.1 protocol

    LVL 51

    Assisted Solution

    Cache-Control: and Expires: are empty, hence invalid, so a proper browser only uses Last-Modified to decide if the page needs to be requested again (and browsers behave different here, depending on the date).

    You need to write proper headers.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
    In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    761 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

    8 Experts available now in Live!

    Get 1:1 Help Now