Forum Moderators: open

Message Too Old, No Replies

Server response - last modified

Doesn't show for .asp sites, does for .htm

         

millie

10:48 am on Jan 28, 2004 (gmt 0)

10+ Year Member



Hi all,
I understand that having "Last Modified" in the server header info is important for SEs.

I ran some server header checks on our sites (using SEWorld tool) and all the .htm sites show Last Modified OK, but none of the .asp sites show this info.

How can I put Last Modified in an .asp site please?

Thanks very much in advance,
Millie

pageoneresults

10:56 am on Jan 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Dynamic pages (asp, cfm, jsp, php) will not produce a Last Modified date in the server headers. Only static pages (.htm) will produce this.

On the other hand, the server should be configured to support the If-Modified-Since date which is what is served for dynamic pages.

When I first started studying server headers, I couldn't figure out why my asp pages were not returning Last Modified dates. After a little bit of research I found out why.

pageoneresults

11:00 am on Jan 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Pssst, a great related topic here...

Are you using If-Modified-Since? [webmasterworld.com]

millie

11:44 am on Jan 28, 2004 (gmt 0)

10+ Year Member



Thank you VERY much POR!
M

millie

1:38 pm on Jan 28, 2004 (gmt 0)

10+ Year Member



I showed the thread POR suggested to the designer and he said "I've done it" but it turned out he'd just put it so it always shows today's date. Now I don't know anything about coding etc but that didn't sound good to me.

So I got him to change it, but now I'm a bit scared and definitely don't want to get on the wrong side of the SEs.

Would you mind casting your eye over this code to see if it looks right?

<%

thisfile = Request.ServerVariables("SCRIPT_NAME")

thisfile = Server.MapPath(thisfile)

set fso = Server.CreateObject("Scripting.FileSystemObject")

set fs = fso.getfile(thisfile)

dlm = fs.datelastmodified

set fs = nothing: set fso = nothing

%>

<%

Response.AddHeader "Last-modified",dlm

%>

Thank you very much for your time,
Millie

Xoc

5:20 pm on Jan 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This will do what you want:

<%
Function RFC1123Date(dateSpec)
Dim astrDay
Dim astrNum
Dim astrMonth

astrDay = Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat")
astrNum = Array( "00", _
"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", _
"11", "12", "13", "14", "15", "16", "17", "18", "19", "20", _
"21", "22", "23", "24", "25", "26", "27", "28", "29", "30", _
"31", "32", "33", "34", "35", "36", "37", "38", "39", "40", _
"41", "42", "43", "44", "45", "46", "47", "48", "49", "50", _
"51", "52", "53", "54", "55", "56", "57", "58", "59", "60")
astrMonth = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", _
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
RFC1123Date = astrDay(WeekDay(dateSpec) - 1) & ", " & astrNum(Day(dateSpec)) _
& " " & astrMonth(Month(dateSpec) - 1) & " " & Year(dateSpec) _
& " " & astrNum(Hour(dateSpec)) & ":" & astrNum(Minute(dateSpec)) _
& ":" & astrNum(Second(dateSpec)) & " PST")
End Function

Call Response.AddHeader("Last-Modified", RFC1123Date(Now))
%>

I have used code like this for years without problems.

You need to change the final PST to whatever your time zone abbreviation is for where the server is located, EST, CST, MST, PST, etc.

The Last-Modified date field must use IETF date format given in RFC1123, [ietf.org ], in section 5.2.14, which references RFC822, [ietf.org ], in section 5.

The code shown above, of course, only feeds the current time, but you want to combine that with the code you did because the date format you are using isn't correct.

pageoneresults

6:21 pm on Jan 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



XOC, can I assume that IIS is not configured out of the box to support the If-Modified-Since date? Also, where does the 304 come into play here?

P.S. My understanding of all this...

userAgent request the server headers for a page. If the page has not been modified, the server sends a 304 response. If the page has been modified, it sends a 200 response with the last modified date. Is that correct?

Xoc

9:05 pm on Jan 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There is no way that IIS can know for a dynamic page on whether the content has changed, since the content is created on the fly, so at least for .asp/aspx pages, it can't. It could possibly for static content such as .htm pages or images. I don't know if it does. I do see a fair number of 304's showing up in my server logs, but I've never investigated the headers to see if it is working.

plumsauce

12:30 am on Jan 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




I can confirm that the headers work properly
for static content in iis/5.0

millie

9:57 am on Jan 29, 2004 (gmt 0)

10+ Year Member



Thank you very much for your help.

Can I possibly double-check this with you ...

For dynamic content you have to set the If-Modified-Since date as the CURRENT date / time because if the last published date is used any new content that is added via the database is not seen by either robots or people, even when the page is refreshed.

Is this correct? If it is correct it leads me to ask:

Since the current date/time is not actually the last modified date isn't this effectively "tricking" the search engines? And therefore dangerous ground?

Yours humbly, Millie

Xoc

5:17 pm on Jan 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There is no way for the search engines to know if you just happened to touch all the files in your web server, but not make changes. There are a lot of upload programs that always uploads the entire web site if you change even one file. The web server would then report the upload time as the modified date. If the search engines penalized this, they would be penalizing everyone who used such an upload program.

One example of such a program is Visual Studio .NET, the primary development environment for developing .NET web sites. It doesn't try to compare files on the development machine versus the web server. It just blasts the entire site up there if you fix a typo on just one page. It is one of the most annoying "features" it has, because FrontPage does a better job than that! So no, the search engines can't penalize you for changing the Last-Modifed header.