ASP 101 - Active Server Pages 101 - Web06
The Place ASP Developers Go!

Please visit our partners

Windows Technology Windows Technology
15 Seconds
ASP 101
ASP Wire
VB Forums
VB Wire
internet.commerce internet.commerce
Partners & Affiliates

ASP 101 is an site
ASP 101 is an site
Internet News
Small Business
Personal Technology

Corporate Info
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash

ASP Source Code:
' This sample examines the caching side of things.  For more
' details on the HTTP request aspect of the code, see our two
' previous HTTP samples:
' (WinHttp version)
' (older MSXML version)
Dim strCached  ' string to hold text telling user if page was cached
' Check to see if the expiration date of the cached data has passed.
If Application("http_cache_sample_expires") < Now() Then
	Dim objWinHttp ' HTTP request object
	Set objWinHttp = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
	objWinHttp.Open "GET", ""
	' If we get a valid response then we save the data to an
	' application variable and set another to indicate how long
	' the data should be kept.
	If objWinHttp.Status = "200" Then
		' Save the response to an application level variable
		Application("http_cache_sample_content") = objWinHttp.ResponseText
		' Set the expiration time.  As an example I'm adding 1 minute to
		' the current time, but you can do whatever works best for you.
		Application("http_cache_sample_expires") = DateAdd("n", 1, Now())
	End If
	' Trash our HTTP object now that I'm finished with it.
	Set objWinHttp = Nothing
	strCached = "Not Cached"
	strCached = "Cached"
End If
<h2>Retreived HTML (<%= strCached %>):</h2>
<table border="1" cellpadding="0" cellspacing="0">
<%= Server.HtmlEncode(Application("http_cache_sample_content")) %>
The cached data will expire at: <%= Server.HtmlEncode(Application("http_cache_sample_expires")) %>
The content in the box is retrieved via HTTP and is then cached for up to one minute.
As you refresh the page, pay attention to the timestamp in the returned HTML.
For comparison, it is currently: <%= Now() %>

Back the the Sample Output

Back to the Sample Index

Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback
The Network for Technology Professionals



Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers