Forum OpenACS Q&A: no headers from ns_return!?

Collapse
Posted by Jonathan Ellis on
I'm trying to convince IE not to cache a page, and it's not working. It doesn't seem to be IE's fault though b/c I don't even get the headers when I telnet; not even the HTTP OK header.

Here's my script:

ns_set put [ns_conn outputheaders] cache-control "max-age=0, must-
revalidate"
ns_return 200 text/html "test"
Here's what I get:
# telnet www.carnageblender.com 8001
Trying 10.0.0.20...
Connected to www.carnageblender.com.
Escape character is '^]'.
GET /public/test.tcl
testConnection closed by foreign host.
Collapse
Posted by David Walker on
Change your telnet request to

GET /public/test.tcl HTTP/1.1
Host: www.carnageblender.com

Collapse
Posted by Jonathan Ellis on
Thanks.  The headers are getting sent after all. :)  #$@%@#$% IE... works in netscape fine. :(
Collapse
Posted by Tilmann Singer on
Did you experiment with Pragma: no-cache and Expires: headers? Those two commands worked for me:


ns_set icput [ns_conn outputheaders] "Pragma" "no-cache"

ns_setexpires 0

Also if you have control over the referencing link then you can append a bogus variable with some random value to the url to make sure IE really reloads the page (very ugly though ...)

Collapse
Posted by Jonathan Ellis on
I tried what you suggested, Tilmann, and when that didn't work I also tried
    set s [ns_set new]
    ns_set put $s "Pragma" "No-Cache"
    ns_set put $s "Expires" "0"
    ns_set move $s [ns_conn outputheaders]
    ns_set move [ns_conn outputheaders] $s
because MS says the pragma may need to be the first header. Still no luck, either with NN or IE. Checking with telnet shows they're being sent correctly. Very frustrating. :(
Collapse
Posted by Jonathan Ellis on
I went with the "pass unnecessary variables along" option.  The cool thing is that since it's only one image on the page I'm worried about, I created a tcl script to send that image, so everything else can still be cached.

Incidently cache-control doesn't seem to be an option after all, b/c aolserver only does HTTP 1.0, not 1.1.

Collapse
Posted by Tilmann Singer on
Some browsers behave different when caching images compared to pages - IE seems to assume that images never change at all, so they never need to be reloaded, regardless of the numerous "please don't cache me" headers it gets sent. The alternating bogus parameter approach might be the only solution in this case.
Collapse
Posted by Peter Breugel on
Use

wget -S http://www.carnageblender.com 8001

This will return all the headers.