Question

I have a perl generated page. The contents of this page change every 30 minutes, so I'm setting $r->set_last_modified() to the time the contents last changed.

That all works well and I can see the correct header arriving at my browser.

When I refresh the page, I see my browser uses the correct "If-Modified-Since" header in the request to the server, but Apache2 ignores this and re-sends the entire page.

How can I get Apache2 to behave correctly and respond with a "HTTP/1.x 304 Not Modified" ?

(The "last-modified" / "if-modified-since" headers are handled correctly when requesting static content from the same Apache2 process.)

Thanks for any help.

EDIT: Are my expectations wrong? Do I have to explicitly handle inbound If-Modified-Since headers in my perl script?

Was it helpful?

Solution

Apache won't store your last-modified value when it processes a request. So in order to decide whether something was modified it will have to run your application.

OTHER TIPS

Sadly, yes, your expectations are wrong.

At the point where you basically say to Apache "OK, I'm dealing with this request...", Apache is going to hand over responsibility for everything to you. If you want the request to honour If-Modified-Since, it's down to your code.

Face it, this is the right behaviour, since there's no way Apache can know what you /really/ mean by 'modified' in a Perl handler: it might be that the best check is to go query your backend DB for a timestamp on a record, for example....

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top