Welcome to WebmasterWorld Guest from 54.83.93.85

Forum Moderators: phranque

Message Too Old, No Replies

How do you get HTTP_IF_MODIFIED_SINCE set up?

     
3:03 am on Jun 22, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 5, 2003
posts:809
votes: 0


How do you get HTTP_IF_MODIFIED_SINCE set up? GoogleGuy says it'll save a bunch of bandwidth. I can only get the
'Last-Modified: Sun, 22 Jun 2003 02:57:23 GMT'
message to show up when I enter .txt files at the Server Header Check [webmasterworld.com]
3:21 am on June 22, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


Jesse_Smith,

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>

Technically, the "header unset" should not be required, but this server has some sort of problem with "header-append," so I just clear the header and start over with exactly what I want.
<FilesMatch> is described in the Apache core [httpd.apache.org] documentation.

HTH,
Jim

4:41 am on June 22, 2003 (gmt 0)

Preferred Member

10+ Year Member

joined:July 16, 2001
posts:545
votes: 0


I do this entirely in PHP for my own sites. Basically, I read in the date sent along with the GET(the browser/bot sends the date it last pulled your page) and test it against the date I last updated. If my date is newer than theirs, I send the whole page. Otherwise, I just send the headers.

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.

5:00 am on June 22, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


Jesse_Smith,

Also, if you are using SSI includes in files named .html, you'll need to set XBitHack Full and then chmod the files to 746 in order to get the Last-Modified date of the html file.

See Apache mod_include

Jim

5:35 am on June 22, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 5, 2003
posts:809
votes: 0


I use SSI in .shtml files. That .htaccess stuff generates Internel Server Errors, even on .shtml files.

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.

8:47 pm on June 22, 2003 (gmt 0)

Preferred Member

10+ Year Member

joined:July 16, 2001
posts:545
votes: 0


apache is programmed to issue lastmodified headers for any file it thinks is not dynamically generated. Your .shtml files don't fit in that list, so they don't get them, unless you get the stuff jdMorgan's given you working.

Curiosity, are you currently using any scripting language other than SSI?

9:17 pm on June 22, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


Jesse,

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

2:23 am on June 24, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 5, 2003
posts:809
votes: 0


New question. Is there a telnet comand to do a mass chmod, to chmod every file in a directory at the same time?

With the .htaccess file saying 'XBitHack Full' it works, with the right chmod. It won't work with 746, but it does work with 555.

3:18 am on June 24, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


Jesse_Smith,

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

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members