Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Last-Modified Header

Quote Reply
Last-Modified Header
Hi,

we're serving dynamic pages (Links SQL 2.1.2). How can we force the script to send a "Last-Modified"-Header? Or even better, "Last-Modified" and "Expires"?

TIA,

Peter
Quote Reply
Re: [Petrocelli] Last-Modified Header In reply to
Hi Peter,

Gossamer Links does not support sending a last modified header in dynamic mode (as that implies supporting conditional requests). You can setup your caching policies with expires headers using mod_expires:

http://httpd.apache.org/...mod/mod_expires.html

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Last-Modified Header In reply to
Hi Alex,

if I am not mistaken, every cgi output is being prepended with some header information. I want to do something like
Code:
print "Last-Modified: $mod_string\n";
print "Expires: $exp_string\n";
before Links SQL does
Code:
print "Content-Type: text/html\n\n";

I am aware of mod_expires, but you can't use it to set the "last modified" date. I already spotted "sub header" in CGI.pm to be the place where you push various lines to the header array, but I did not succeed adding a "Last-Modified" line. Can you help me?

Kind regards,

Peter
Quote Reply
Re: [Petrocelli] Last-Modified Header In reply to
Hi,

What would you set the last modified date to? How would you handle a conditional request by the client? I'm not sure what you are trying to do. =)

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Last-Modified Header In reply to
I would like to set the date of all category pages to always be - let's say - the first day of the current month.

Background: Googlebot seems to be picky when dynamically served pages (those without a last modified stamp) are to be indexed for the first time. So I want to make him see them as already "settled" static pages which he can trust without further hesitation.

Peter

Last edited by:

Petrocelli: Apr 13, 2005, 2:11 PM
Quote Reply
Re: [Petrocelli] Last-Modified Header In reply to
Hi,

If you just wanted to pick an arbitrary date and not try to handle conditional requests, then you could add the headers by editing Links/User/Page.pm and generate_category_page, and change:

print $IN->header();

to:

print $IN->header( '-Last-Modified' => $date, '-Expires' => $date2 );

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Last-Modified Header In reply to
Hi Alex,

many thanks for your help. What am I doing wrong? I tried

Code:
my $mod_string = "Wed, 13 Apr 2005 12:00:00 GMT";

print $IN->header( '-Last-Modified' => $mod_string );
but this doesn't seem to set the header (I cleared the browser cache and also checked with an external tool). Many thanks in advance for your further assistance,

Peter
Quote Reply
Re: [Petrocelli] Last-Modified Header In reply to
Hi,

Oops, by default the $mod_string is escaped. To avoid it being escaped, pass in a reference:

Code:
alex@penguin library $ perl -MGT::CGI -le 'print GT::CGI->header( "-Last-Modified" => \"Wed, 13 Apr 2005 12:00:00 GMT")'
Content-type: text/html
Last-Modified: Wed, 13 Apr 2005 12:00:00 GMT


alex@penguin library $

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Last-Modified Header In reply to
Yep, this does it. Many thanks!

Yours,

Peter