~ overflow ~

Archive for May 7th, 2009

last-modified headers missing!

by z3n on May.07, 2009, under Coding, Tips & Hints

Problem:

last-modified headers are missing on your httpd servers responses.

Solution:

This is happening because the page you’re testing is being taken as SSI, meaning that it’s being processed in the server first.

I really like to use SSI on my pages, even if they are static, it’s much easier to build them, since the headers and footers are usually all the same, and it’s much easier when you need to modify one of those, editing 2 files changes the whole site.

While building a sitemap script i noticed that server wasn’t returning the last-modified header, which is crucial for the sitemap xml to work right.

After some digging i found out about the XBitHack apache feature, which is able to return the last-modified header, even for cgi scripts.

You can enable this on the server config or on the .htaccess, for me, it was better enable only on the .htaccess, since this might cause unexpected issues and slowdown on the server, as apache site meantion, this last-modified date for SSI pages is harder to be pooled and uses more cpu.

So the solution is simple:

XBitHack On

in some cases you would need to enable it full,

XBitHack Full

This will make the files with execution mode enabled (chmod +x) to have a last-modified header on it, the full mode will enable group checking as well. Check apache docs for more info.

Sources:

Apache SSI Tutorial

XBitHack Directive

Other usefull info:

E-Tag vs Expires

same issue on apache 1.3

Bonus:

Little script to show headers of a page (use it on prompt, php script.php <url>):

<?php

$fp=fopen($argv[1],”r”);
print_r(stream_get_meta_data($fp));

?>

Leave a Comment :, , , , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!