• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 251
  • Last Modified:

Disable caching

I am writing a web-based application and I want that certain pages generated by my Perl Script should not be cached at all.( for security reason)
How can I disable caching thru Perl Script??
1 Solution
try to add expire in you script:
I assume you use CGI.pm

print $q->header(-expires=>'-1d',-pragma=>'no-cache');

amreshAuthor Commented:
I never used CGI.pm. I am very new to this field. Kindly elaborate or suggest some
other solution.

CGI.pm is a commonly used Perl module that takes care of most CGI-related tasks, making writing your CGI-scripts a lot easier.  it's quite large though, so when you only need small things done or have a heavy load you won't load all of it.

to make sure that the output of your CGI isn't cached you need to send several headers to the browser.  which headers to use is found in the RFCs for HTTP, RFCS 1945 and 2068 for HTTP/1.0 and HTTP/1.1 respectively.  for HTTP/1.0 you want to send out the "Expires" or the "Pragma" header.  for HTTP/1.1 the header is called "Cache-control".  in straight Perl the script would do something like:

print "Content-type: text/html\n"; # provided we're outputting HTML
print "Expires: Thu, 1 Jan 1970 00:00:00 GMT\n"; # expired on epoch
print "Pragma: no-cache\n"; # pragma as according to RFC 1945
print "Cache-control: no-cache\n"; # cache-control, RFC 2068 (HTTP/1.1)
print "\n"; # for last \n\n marking the end of the header

This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects the problem and the expert will now receive these points; points verified.

Please click on your Member Profile and select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.  If you are an EE Pro user, you can also choose Power Search to find all your open questions.

This is the Community Support link, if help is needed, along with the link to All Topics which reflects many TAs recently added.

Thank you,
Moderator @ Experts Exchange
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now