Discussion:
no_cache(1)
(too old to reply)
Michel Jansen
2015-09-07 20:15:23 UTC
Permalink
if i add $r->no_cache(1) to an ajax responder perl script the browser
receives a 0 in the response, what am i doing wrong?


Regards,

Michel
Paul Silevitch
2015-09-07 20:22:47 UTC
Permalink
Hello Michel,

Are you calling $r->no_cache before any response data has been sent? When
you say the browser receives a '0' in the response, what do you mean
exactly?

Thanks,

Paul
Post by Michel Jansen
if i add $r->no_cache(1) to an ajax responder perl script the browser
receives a 0 in the response, what am i doing wrong?
Regards,
Michel
Paul Silevitch
2015-09-07 20:51:51 UTC
Permalink
Weird.

Try the following instead:

$r->headers_out->set('Pragma' => 'no-cache');
$r->headers_out->set('Cache-Control' => 'no-cache');

I've actually never used 'no_cache' before but instead used the above two
lines.

Let me know if it works for you.

Thanks,

Paul
Hi Paul,
Helle Michel,
Are you calling $r->no_cache before any response data has been sent?
Yes. Before setting the content type to text/html.
When you say the browser receives a '0' in the response, what do you mean
exactly?
My Ajax responder sends some fields separated by | which are being split
and then distributed into a page. The 0 is received by the JavaScript which
performes the Ajax request as first response and is then connected to the
first field.
Do i make sense ?
Thanks,
Paul
Post by Michel Jansen
if i add $r->no_cache(1) to an ajax responder perl script the browser
receives a 0 in the response, what am i doing wrong?
Regards,
Michel
John Dunlap
2015-09-08 16:05:39 UTC
Permalink
I am going to echo Paul's comments. If you've used a print anywhere in your
code prior to invoking $r->no_cache(1); then it's not going to work because
sending of even a single byte of content will cause apache to send the
response headers and you are then unable to modify the response headers
once they have already been sent.
Post by Paul Silevitch
Weird.
$r->headers_out->set('Pragma' => 'no-cache');
$r->headers_out->set('Cache-Control' => 'no-cache');
I've actually never used 'no_cache' before but instead used the above two
lines.
Let me know if it works for you.
Thanks,
Paul
Hi Paul,
Helle Michel,
Are you calling $r->no_cache before any response data has been sent?
Yes. Before setting the content type to text/html.
When you say the browser receives a '0' in the response, what do you mean
exactly?
My Ajax responder sends some fields separated by | which are being split
and then distributed into a page. The 0 is received by the JavaScript which
performes the Ajax request as first response and is then connected to the
first field.
Do i make sense ?
Thanks,
Paul
Post by Michel Jansen
if i add $r->no_cache(1) to an ajax responder perl script the browser
receives a 0 in the response, what am i doing wrong?
Regards,
Michel
--
John Dunlap
*CTO | Lariat *

*Direct:*
****@lariat.co <***@lariat.co>*

*Customer Service:*
877.268.6667
***@lariat.co
John Dunlap
2015-09-09 19:41:38 UTC
Permalink
Michel, if you go into your browser's network debugging console(usually
CTRL+SHIFT+I in modern browsers) and look at the response headers for the
ajax request, do you see a cache-control header? If so, what does it say?
If you're seeing something similar to the following:

Cache-control:no-cache

then $r->no_cache(1) is working and the problem lies elsewhere in your
application.

Cheers!
John
Hi Paul,
Helle Michel,
Are you calling $r->no_cache before any response data has been sent?
Yes. Before setting the content type to text/html.
When you say the browser receives a '0' in the response, what do you mean
exactly?
My Ajax responder sends some fields separated by | which are being split
and then distributed into a page. The 0 is received by the JavaScript which
performes the Ajax request as first response and is then connected to the
first field.
Do i make sense ?
Thanks,
Paul
Post by Michel Jansen
if i add $r->no_cache(1) to an ajax responder perl script the browser
receives a 0 in the response, what am i doing wrong?
Regards,
Michel
--
John Dunlap
*CTO | Lariat *

*Direct:*
****@lariat.co <***@lariat.co>*

*Customer Service:*
877.268.6667
***@lariat.co
Michel Jansen
2015-09-07 20:39:26 UTC
Permalink
Hi Paul,
Helle Michel,
Are you calling $r->no_cache before any response data has been sent?
Yes. Before setting the content type to text/html.
When you say the browser receives a '0' in the response, what do you mean exactly?
My Ajax responder sends some fields separated by | which are being split and then distributed into a page. The 0 is received by the JavaScript which performes the Ajax request as first response and is then connected to the first field.

Do i make sense ?
Thanks,
Paul
if i add $r->no_cache(1) to an ajax responder perl script the browser receives a 0 in the response, what am i doing wrong?
Regards,
Michel
Loading...