Forum Moderators: phranque
See Apache mod_headers [httpd.apache.org] and mod_expires [httpd.apache.org].
Working example:
# Set up Cache Control headers
ExpiresActive On
# Default - Set http header to expire everything one week from last access, set must-revalidate
ExpiresDefault A604800
Header append Cache-Control: "must-revalidate"
# Apply a customized Cache-Control header to frequently-updated files
<FilesMatch "^(hserch¦hlocat¦binlog¦test)\.html$">
ExpiresDefault A1
Header unset Cache-Control:
Header append Cache-Control: "no-cache, must-revalidate"
</FilesMatch>
<FilesMatch "^(calend¦event\_sched¦4[0-9]{2}.?)\.html$">
ExpiresDefault A7200
</FilesMatch>
<FilesMatch "^index\.htm">
ExpiresDefault A7200
</FilesMatch>
<FilesMatch "^robots\.txt$">
ExpiresDefault A7200
</FilesMatch>
HTH,
Jim
As an aside, I don't know if the processing time involved outweighs the bandwidth I'm saving, but I do see browsers requesting and getting Page Not Modified messages.
If anyone's interested in the code, sticky me and I'll clean it up a bit and post it.
It looks like I don't get it because there .shtml files.
.txt and .html give out
HTTP/1.1 200 OK
Date: Sun, 22 Jun 2003 06:18:56 GMT
Server: Apache/1.3.20 Sun Cobalt (Unix) mod_ssl/2.8.4 OpenSSL/0.9.6b PHP/4.0.6 mod_auth_pam_external/0.1 FrontPage/4.0.4.3 mod_perl/1.25
Last-Modified: Thu, 16 Jan 2003 02:48:07 GMT
ETag: "127263-358-3e261d67"
Accept-Ranges: bytes
Content-Length: 856
Connection: close
Content-Type: text/plain
while .shtml files give out
HTTP/1.1 200 OK
Date: Sun, 22 Jun 2003 06:19:55 GMT
Server: Apache/1.3.20 Sun Cobalt (Unix) mod_ssl/2.8.4 OpenSSL/0.9.6b PHP/4.0.6 mod_auth_pam_external/0.1 FrontPage/4.0.4.3 mod_perl/1.25
Connection: close
Content-Type: text/html
Simply changing the file name from file.shtml to file.html or file.txt made the Last-Modified come up, then when the file is changed back to file.shtml, it didn't show up. All the files are .shtml.
I suspect the 500-Server Error problem is that I forgot to tell you to change the broken vertical pipe "¦" characters to solid vertical pipe characters - They get modified by posting on this board.
As for the Last-Modified dates on .shtml files, you probably can't get them, because .shtml is a dynamically-generated file type. One way to get around this is to rename those files to .html and use XBitHack. Again, see Apache mod_include [httpd.apache.org].
Slade's point about other scripting languages is a good one. We've just had a series of posts [webmasterworld.com] on SSI interfering with PHP.
Jim
Interesting... You should only have to change the group-execute bit setting according to the documentation.
It's just a unix command... chmod 555 *.html
I suppose you could add -R to have it recurse down through all subdirectories:
chmod -R 555 *.html
Do a search for "chmod man page" to bring up many copies of the unix manual page on chmod.
HTH,
Jim