View Full Version : HTTP Headers
I am having a problem using document.lastModified in a client script. From what I can tell, the Last-Modified: HTTP Header is not being sent for all of my pages. It works with my main page (index.aspx), but doesn?t work with any of my other pages.
You can check the headers with this url: http://www.delorie.com/web/headers.html
When I type in http://www.alleshouse.net/index.aspx. I get this:
TTP/1.1 200 OK
Cache-Control: public
Content-Length: 4713
Content-Type: text/html; charset=utf-8
Expires: Fri, 27 Feb 2004 04:37:56 GMT
Last-Modified: Fri, 27 Feb 2004 03:37:56 GMT
Server: Microsoft-IIS/6.0
X-AspNet-Version: 1.1.4322
X-Powered-By: ASP.NET
MicrosoftOfficeWebServer: 5.0_Pub
Date: Fri, 27 Feb 2004 03:47:27 GMT
Connection: close
However, when I type in any other page, (for instance, http://www.alleshouse.net/contact_information.aspx) I get this:
HTTP/1.1 200 OK
Connection: close
Date: Fri, 27 Feb 2004 03:50:47 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
MicrosoftOfficeWebServer: 5.0_Pub
X-AspNet-Version: 1.1.4322
Set-Cookie: ASP.NET_SessionId=dbdhhwqpxfzunt3ofdpxqinb; path=/
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Length: 3693
Any help would be appreciated.
bruce
02-27-2004, 05:26 AM
I got totally different result when i tried it
Try use the temporary URL to test to be completely sure.
[b]quote:Originally posted by Me
I am having a problem using document.lastModified in a client script. From what I can tell, the Last-Modified: HTTP Header is not being sent for all of my pages. It works with my main page (index.aspx), but doesn?t work with any of my other pages.
You can check the headers with this url: http://www.delorie.com/web/headers.html
When I type in http://www.alleshouse.net/index.aspx. I get this:
TTP/1.1 200 OK
Cache-Control: public
Content-Length: 4713
Content-Type: text/html; charset=utf-8
Expires: Fri, 27 Feb 2004 04:37:56 GMT
Last-Modified: Fri, 27 Feb 2004 03:37:56 GMT
Server: Microsoft-IIS/6.0
X-AspNet-Version: 1.1.4322
X-Powered-By: ASP.NET
MicrosoftOfficeWebServer: 5.0_Pub
Date: Fri, 27 Feb 2004 03:47:27 GMT
Connection: close
However, when I type in any other page, (for instance, http://www.alleshouse.net/contact_information.aspx) I get this:
HTTP/1.1 200 OK
Connection: close
Date: Fri, 27 Feb 2004 03:50:47 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
MicrosoftOfficeWebServer: 5.0_Pub
X-AspNet-Version: 1.1.4322
Set-Cookie: ASP.NET_SessionId=dbdhhwqpxfzunt3ofdpxqinb; path=/
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Length: 3693
Any help would be appreciated.
</blockquote id="quote"></font id="quote">
That?s really strange! I did as you suggested and tried the temporary url and came up with identical results. I?m not sure how you got different results.
Just out of curiosity, what determines the HTTP headers that are sent to the client? If I?m not mistaken, this is all done on the server. I don?t think there is anything I could add in my code to force the headers to be sent. Is this correct?
[b]quote:Originally posted by bruce
I got totally different result when i tried it
Try use the temporary URL to test to be completely sure.
[b]quote:Originally posted by Me
I am having a problem using document.lastModified in a client script. From what I can tell, the Last-Modified: HTTP Header is not being sent for all of my pages. It works with my main page (index.aspx), but doesn?t work with any of my other pages.
You can check the headers with this url: http://www.delorie.com/web/headers.html
When I type in http://www.alleshouse.net/index.aspx. I get this:
TTP/1.1 200 OK
Cache-Control: public
Content-Length: 4713
Content-Type: text/html; charset=utf-8
Expires: Fri, 27 Feb 2004 04:37:56 GMT
Last-Modified: Fri, 27 Feb 2004 03:37:56 GMT
Server: Microsoft-IIS/6.0
X-AspNet-Version: 1.1.4322
X-Powered-By: ASP.NET
MicrosoftOfficeWebServer: 5.0_Pub
Date: Fri, 27 Feb 2004 03:47:27 GMT
Connection: close
However, when I type in any other page, (for instance, http://www.alleshouse.net/contact_information.aspx) I get this:
HTTP/1.1 200 OK
Connection: close
Date: Fri, 27 Feb 2004 03:50:47 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
MicrosoftOfficeWebServer: 5.0_Pub
X-AspNet-Version: 1.1.4322
Set-Cookie: ASP.NET_SessionId=dbdhhwqpxfzunt3ofdpxqinb; path=/
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Length: 3693
Any help would be appreciated.
</blockquote id="quote"></font id="quote">
</blockquote id="quote"></font id="quote">
OK, I figured out a few things. ASP.NET pages do not send the ?Last-Modified? header. This is kind of strange, but there are a few ways around it.
One thing you can do is simply set the header within your code.
ie (C#):
[quote]this.Response.AddHeader("Last-Modified","Fri,27Feb200003:37:56GMT");
</CODE>
The problem with this is that I have to update the date every time I change it. Additionally, it won?t work with pages that have the content cached on the server.
Therefore, I came up with another solution. Instead of trying to get the time last modified with client code, I did it with server code. I put the code below in a user control and it works great.
[quote]stringpath;//Paththepagethisusercontrolisrenderedin
System.DateTimelast_updated;//thedatethefilewaslastupdated
path=this.Parent.Page.Request.ServerVariables["Path_Translated"];
last_updated=System.IO.File.GetLastWriteTime(path) ;
this.lblLastUpdated.Text=last_updated.ToShortDateS tring()+""+last_updated.ToShortTimeString();
</CODE>
bruce
02-29-2004, 04:19 AM
To my knowledge, http header is set by the server.
I am not sure if you can manipulate it through code. I would try search in google.
[b]quote:Originally posted by Me
That?s really strange! I did as you suggested and tried the temporary url and came up with identical results. I?m not sure how you got different results.
Just out of curiosity, what determines the HTTP headers that are sent to the client? If I?m not mistaken, this is all done on the server. I don?t think there is anything I could add in my code to force the headers to be sent. Is this correct?
[b]quote:Originally posted by bruce
I got totally different result when i tried it
Try use the temporary URL to test to be completely sure.
[b]quote:Originally posted by Me
I am having a problem using document.lastModified in a client script. From what I can tell, the Last-Modified: HTTP Header is not being sent for all of my pages. It works with my main page (index.aspx), but doesn?t work with any of my other pages.
You can check the headers with this url: http://www.delorie.com/web/headers.html
When I type in http://www.alleshouse.net/index.aspx. I get this:
TTP/1.1 200 OK
Cache-Control: public
Content-Length: 4713
Content-Type: text/html; charset=utf-8
Expires: Fri, 27 Feb 2004 04:37:56 GMT
Last-Modified: Fri, 27 Feb 2004 03:37:56 GMT
Server: Microsoft-IIS/6.0
X-AspNet-Version: 1.1.4322
X-Powered-By: ASP.NET
MicrosoftOfficeWebServer: 5.0_Pub
Date: Fri, 27 Feb 2004 03:47:27 GMT
Connection: close
However, when I type in any other page, (for instance, http://www.alleshouse.net/contact_information.aspx) I get this:
HTTP/1.1 200 OK
Connection: close
Date: Fri, 27 Feb 2004 03:50:47 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
MicrosoftOfficeWebServer: 5.0_Pub
X-AspNet-Version: 1.1.4322
Set-Cookie: ASP.NET_SessionId=dbdhhwqpxfzunt3ofdpxqinb; path=/
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Length: 3693
Any help would be appreciated.
</blockquote id="quote"></font id="quote">
</blockquote id="quote"></font id="quote">
</blockquote id="quote"></font id="quote">
vBulletin® ©Jelsoft Enterprises Ltd.