server header and cache

Posted on 2005-04-20
Medium Priority
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('http://xyz.com/');

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

ramazanyich earned 1000 total points
ID: 13831499
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

ahoffmann earned 1000 total points
ID: 13852943
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.

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
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 …
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…
Suggested Courses
Course of the Month6 days, 10 hours left to enroll

593 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