Forum Moderators: open
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
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.
Are you using If-Modified-Since? [webmasterworld.com]
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
<%
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.
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?
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
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.