Solved

html not from the cache

Posted on 1998-12-02
12
177 Views
Last Modified: 2013-12-25
I preparing html pages using cgi program (written in java).
Because few links in my site are running the program, which
prepare as output an html page out of database, I want that when someone press on those links the browser will not go to the cache but to the program and will 'build' the page again. how can I do it without changing the browser's preferences ???
0
Comment
Question by:neta
  • 5
  • 3
  • 2
  • +1
12 Comments
 
LVL 1

Expert Comment

by:ptruman
ID: 1829847
IIRC, any link to a program/cgi etc will NOT load from the cache.
Esp. if you build an expiry META into your HTML output....

0
 
LVL 11

Expert Comment

by:mouatts
ID: 1829848
ptruman is partially correct in that normally CGI is not loaded however this is not always the case. Generally the Web Server does not output any HTTP headers on a CGI call as it leaves this for the CGI call to do. So it then depends on how the browser works. IE3 has a nasty habit of caching CGI output when it doesn't understand the extension of the link (ie it isn't .cgi which it doesn't have to be). Such behaviour is totally contrary to the HTTP standard but you try telling Microsoft.

To counter this your CGI will need to output the pragma no-cache HTTP header.

ptruman is incorrect to suggest a Meta tag as the head section of CGI output is not normally parsed by the server and as I keep saying in various answers the browsers don't read the HTTP-EQUIV meta tags either.


Steve
0
 
LVL 11

Expert Comment

by:mouatts
ID: 1829849
A minor point the expiry tag will always cause a page to be stored in the cache even though the next time it is accessed it will be discarded and a new one fetched.

Using the expirey trick was used to support browsers that didn't support the no-cache pragma. Such browsers are very rare today.

steve
0
 
LVL 1

Expert Comment

by:ptruman
ID: 1829850
I didnt say META's are normally passed by the server.
You *can* send them as part of your HTML output  :

Content-type: text/html

<HTML>
<META .... etc>

Your browser should then say "Content Expired, Refresh?"
or auto refresh for you when you try and re-hit the page
using back/forward buttons.
IE4 however is too thick to do this.

0
 

Author Comment

by:neta
ID: 1829851
I did not understand what should I do.
I even did not understand the theory, but this is not important.
please try to give me an example of the code I need to add to my html-page made out of a CGI program.
thank anyway, neta.
0
 

Author Comment

by:neta
ID: 1829852
Hello All !!
Tank for your time !
 
Can any one tell me what the META tag should do?
and were should i put it in my html code

To remind you all !!
I Dont want the browser do a downlod from the cache i want
new html page  only from the new conection what should i write in my html code !!!



0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 8

Accepted Solution

by:
MaDdUCK earned 40 total points
ID: 1829853
The meta tag is not a very nice solution of what you want. It would be placed inbetween the <head></head> sections and read the following:

<meta http-equiv="expires" content="0">

this is good for HTML pages, but since you are using CGI, you have more powerful methods:

before you output "Content-type: text/html", write the following:

"Cache-control: no-cache"

in Perl, this would look like this then:

# this is the very first output your cgi should generate:

print "Cache-control: no-cache\r\n";
print "Content-type: text/html\r\n";
print "\r\n"; # don't forget the double newline to terminate http headers.

# the rest of your code goes here.

hope this helps.
MaDdUCK
0
 

Author Comment

by:neta
ID: 1829854
Tank you ALL
and specially YOU MaDdUCK !!

Sorry thats all my points next time i will give more !

Regards.


0
 

Author Comment

by:neta
ID: 1829855
Tank you ALL
and specially YOU MaDdUCK !!

Sorry thats all my points next time i will give more !

Regards.


0
 
LVL 11

Expert Comment

by:mouatts
ID: 1829856
With regard to ptrumans last comments. I thinh that my point was missed in that Metas ARE parsed by the server when the server is parsing headers and converted to HTTP messages and then output.

The browsers do not process HTTP-EQUIV headers and what ever you may think of IE4 it is not wrong in what it does.

Steve
0
 

Author Comment

by:neta
ID: 1829857
There is one more 'neta' who is pretend he is neta, but he is not- I will change my password to prevent him from pretending in the future.
I want to ask MaDdUCK about his suggestion:
Hi, you told mw to write: "Cache-control: no-cache" before the "Content-type: text/html\r\n". but it doesn't work. instead of getting the html page, I get its source code, starting with the line "Content-type: text/html\r\n". It run on unix system.
If you have other suggestions or if I can email you, it would be nice.
thanks, neta.
0
 
LVL 8

Expert Comment

by:MaDdUCK
ID: 1829858
I will look into this in a while. I have finals now and I am really swamped, but maybe on the weekend...
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

747 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

13 Experts available now in Live!

Get 1:1 Help Now