473,626 Members | 3,183 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using If-Modified-Since Http Header

Hi,

I've been reading the <a href="http://www.google.com/webmasters/guidelines.html ">Google WebMaster
Guidelines. Google urges web developers to make use of the If-Modified-Since http header with an
emphasis on saving bandwidth and overhead.

How do I use this header in ASP.NET? Is it there by default or must I explicitly place it in the
Headers collection? How would I inform the GoogleBot of this information?

Thanks,
Roshawn
Nov 19 '05 #1
4 3211
See a running sample at : http://aspnet.asp101.com/samples/modified.aspx

Pick up the code at : http://www.asp101.com/samples/modified_aspx.zip

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
=============== =============== ========
"Roshawn Dawson" <ud****@bellsou th.net> wrote in message
news:ON******** ********@TK2MSF TNGP12.phx.gbl. ..
Hi,

I've been reading the <a href="http://www.google.com/webmasters/guidelines.html ">Google
WebMaster Guidelines. Google urges web developers to make use of the If-Modified-Since
http header with an emphasis on saving bandwidth and overhead.

How do I use this header in ASP.NET? Is it there by default or must I explicitly place
it in the Headers collection? How would I inform the GoogleBot of this information?

Thanks,
Roshawn

Nov 19 '05 #2
Additional info at :

http://www.tutorialized.com/tutorial...-ASP.Net./9068

Here's sample code :

Dim dtNowUnc As DateTime = DateTime.Now(). ToUniversalTime
Dim sDtModHdr = Request.Headers .Get("If-Modified-Since")
' does header contain If-Modified-Since?
If (sDtModHdr <> "") And IsDate(sDtModHd r) Then
' convert to UNC date
Dim dtModHdrUnc As DateTime = Convert.ToDateT ime(sDtModHdr). ToUniversalTime
' if it was within the last 15 minutes, return 304 and exit
If DateTime.Compar e(dtModHdrUnc, dtNowUnc.AddMin utes(-15)) > 0 Then
Response.Status Code = 304
Response.End()
Exit Sub
End If
End If
' add Last-modified to header - FeedDemon stores this with cached
' feed so it's passed to the server the next time the feed is updated
Response.AddHea der("Last-modified", dtNowUnc.ToStri ng("r"))

Picked up from :

http://nick.typepad.com/blog/2004/09...ndwidth_c.html

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
=============== =============== ========
"Juan T. Llibre" <no***********@ nowhere.com> wrote in message
news:uV******** *****@TK2MSFTNG P09.phx.gbl...
See a running sample at : http://aspnet.asp101.com/samples/modified.aspx

Pick up the code at : http://www.asp101.com/samples/modified_aspx.zip

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
=============== =============== ========
"Roshawn Dawson" <ud****@bellsou th.net> wrote in message
news:ON******** ********@TK2MSF TNGP12.phx.gbl. ..
Hi,

I've been reading the <a href="http://www.google.com/webmasters/guidelines.html ">Google
WebMaster Guidelines. Google urges web developers to make use of the If-Modified-Since
http header with an emphasis on saving bandwidth and overhead.

How do I use this header in ASP.NET? Is it there by default or must I explicitly place
it in the Headers collection? How would I inform the GoogleBot of this information?

Thanks,
Roshawn



Nov 19 '05 #3
Thanks Juan. Nice references!! :-)

Juan T. Llibre wrote:
Additional info at :

http://www.tutorialized.com/tutorial...-ASP.Net./9068

Here's sample code :

Dim dtNowUnc As DateTime = DateTime.Now(). ToUniversalTime
Dim sDtModHdr = Request.Headers .Get("If-Modified-Since")
' does header contain If-Modified-Since?
If (sDtModHdr <> "") And IsDate(sDtModHd r) Then
' convert to UNC date
Dim dtModHdrUnc As DateTime = Convert.ToDateT ime(sDtModHdr). ToUniversalTime
' if it was within the last 15 minutes, return 304 and exit
If DateTime.Compar e(dtModHdrUnc, dtNowUnc.AddMin utes(-15)) > 0 Then
Response.Status Code = 304
Response.End()
Exit Sub
End If
End If
' add Last-modified to header - FeedDemon stores this with cached
' feed so it's passed to the server the next time the feed is updated
Response.AddHea der("Last-modified", dtNowUnc.ToStri ng("r"))

Picked up from :

http://nick.typepad.com/blog/2004/09...ndwidth_c.html

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
=============== =============== ========
"Juan T. Llibre" <no***********@ nowhere.com> wrote in message
news:uV******** *****@TK2MSFTNG P09.phx.gbl...
See a running sample at : http://aspnet.asp101.com/samples/modified.aspx

Pick up the code at : http://www.asp101.com/samples/modified_aspx.zip

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.C OM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
============= =============== ==========
"Roshawn Dawson" <ud****@bellsou th.net> wrote in message
news:ON****** **********@TK2M SFTNGP12.phx.gb l...
Hi,

I've been reading the <a href="http://www.google.com/webmasters/guidelines.html ">Google
WebMaster Guidelines. Google urges web developers to make use of the If-Modified-Since
http header with an emphasis on saving bandwidth and overhead.

How do I use this header in ASP.NET? Is it there by default or must I explicitly place
it in the Headers collection? How would I inform the GoogleBot of this information?

Thanks,
Roshawn



Nov 19 '05 #4
Roshawn Dawson wrote:
Hi,

I've been reading the <a
href="http://www.google.com/webmasters/guidelines.html ">Google
WebMaster Guidelines. Google urges web developers to make use of the
If-Modified-Since http header with an emphasis on saving bandwidth
and overhead.

How do I use this header in ASP.NET? Is it there by default or must
I explicitly place it in the Headers collection? How would I inform
the GoogleBot of this information?


Note that in addition to Juan's code-based approach where *you* do all
the work, there's also an easier way: Let infrastructure work its magic.

All you need to do is allow caching of your pages by applying the HTTP
headers "Cache-Control: max-age" and "Expires" (for HTTP 1.0
compatibility).

Setting these headets can be done in code, via page directives or by
configuring your web server to do it.

Cheers,
--
http://www.joergjooss.de
mailto:ne****** **@joergjooss.d e
Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2577
by: Ben Jessel | last post by:
I am in the process of converting my site to using XHTML and CSS. A lot of my sites include tables of data, which are highlighted using javascript rollovers. I have converted my a lot of my single tabled content into unordered lists and then used something like ..html <ul class="aaaa"><li>blah</li></ul>
0
8363
by: grutta | last post by:
I am writing a windows service that will recieve notification when a USB Device is insterted into the machine. I have used the RegisterDeviceNotification and the RegisterServiceCtrlHandlerEx with a handler. The handler portion seems to fail indicating that my parameters are invalid. I am getting an error code 126 when i try to register the handler and 28 when i register for event notification. Any ideas as to what the deal is? I am...
2
5906
by: rawCoder | last post by:
Hi All, I have a *.cer file, a public key of some one and I want to encrypt some thing using this public key. Can someone point me to a sample code for Encrypting some file using X509Certificate ( *.cer file ) so that it can be used to email as attachment. The real part is Encrypting using X509Certificate and CryptoServiceProvider.
17
3498
by: beliavsky | last post by:
Many of my C++ programs have the line using namespace std; but the "Accelerated C++" book of Koenig and Moo has many examples where the library names are included one at a time, for example using std::cin; using std::cout;
8
4368
by: Douglas | last post by:
**** Post for FREE via your newsreader at post.usenet.com **** Hello, The following code does not compile if line 3 is uncommented "using namespace std". I do not understand it. Could somebody explain it to me? I am using MSVC 6.0. Thanks a lot,
12
3368
by: Calum Grant | last post by:
In older C++ computer books, you'll often see using namespace std; even in my 1996 copy of Stroustrup. Nowadays, it seems to be considered better to qualify names to make it clearer what symbol you are using. Are there any articles that support this viewpoint? Is "using namespace" definitively wrong, or just a matter of style? How about when implementing a library "foo", would it not make the code
3
1871
by: Imre | last post by:
As far as I know, the using directive is transitive, and I'm not sure I like this. So I'd like to ask if there's any workaround. Consider this: namespace MyNameSpace { void F(SomeNameSpace::SomeOtherNameSpace::YetAnotherNameSpace::SomeType a); void G(SomeNameSpace::SomeOtherNameSpace::YetAnotherNameSpaceSomeOtherType a);
1
3943
by: Dan Kelley | last post by:
I have 2 projects - 1 Winform project that sends Udp messages using the UdpClient class when a button is clicked, and a Console application that listens for these Udp messages. If I try to use the UdpClient class to receive, it never works. The messages are never received (no exceptions). If I use a normal socket configured to listen for Udp messages, it works perfectly. Below is my sample code. It is only test code - I know the...
6
2163
by: Nathan Kovac | last post by:
Yesterday afternoon I was getting the following errors in a windows service: 'DatabaseManager.DataComponent', 'Error', '3 Errors: Line: 0 - Metadata file 'ScriptingMethods.dll' could not be found Line: 0 - Metadata file 'RemoteLoader.dll' could not be found Line: 0 - Metadata file 'wwScripting.dll' could not be found' Service ran all night fine. This morning I reconnected to the process and the errors are no longer there. Only thing...
2
14648
by: qwedster | last post by:
Folk! How to programattically check if null value exists in database table (using stored procedure)? I know it's possble in the Query Analyzer (see last SQL query batch statements)? But how can I pass null value as parameter to the database stored procedure programattically using C#? Although I can check for empty column (the following code passes string.Empty as parameter but how to pass null value?), I cannot check for null value...
0
8196
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8637
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5574
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4092
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4197
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2625
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.