gethttppage()缓存

anbs01 2009-07-16 04:31:46
为什么用这个方法来生成的静态内容,总是有缓存的?就是说我更新了内容,输出有时总是以前的内容。
'=================================================|
'=================================================|
'获取静态网页内容;
'url 动态页的文件路径;
'=================================================|
function getHTTPPage(url)
dim httpxml
Set httpxml= server.CreateObject("msxml2.XMLHTTP")
httpxml.open "get",url,False
httpxml.send()
if httpxml.readystate<>4 then
exit function
end if
getHTTPPage=bytesToBSTR(Httpxml.responseBody,"GB2312")
set httpxml=nothing
if err.number<>0 then err.Clear
end function ' 2、转换乱玛,直接用xmlhttp调用有中文字符的网页得到的将是乱玛,可以通过adodb.stream组件进行转换
Function BytesToBstr(body,Cset)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
...全文
75 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
lzp4881 2009-07-16
  • 打赏
  • 举报
回复
由于每次产生的时间都不同,加了时间就相当于地址变了,所以不会缓存了
anbs01 2009-07-16
  • 打赏
  • 举报
回复
ok了,带时间就可以了。
但是谁能说说是为什么呢?
lzp4881 2009-07-16
  • 打赏
  • 举报
回复
'=================================================|
'=================================================|
'获取静态网页内容;
'url 动态页的文件路径;
'=================================================|
function getHTTPPage(url)
dim httpxml
Set httpxml= server.CreateObject("msxml2.XMLHTTP")
httpxml.open "get",url,False
httpxml.setRequestHeader "If-Modified-Since","0"
httpxml.send()
if httpxml.readystate<>4 then
exit function
end if
getHTTPPage=bytesToBSTR(Httpxml.responseBody,"GB2312")
set httpxml=nothing
if err.number<>0 then err.Clear
end function ' 2、转换乱玛,直接用xmlhttp调用有中文字符的网页得到的将是乱玛,可以通过adodb.stream组件进行转换
Function BytesToBstr(body,Cset)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
spkl1 2009-07-16
  • 打赏
  • 举报
回复

url后面的参数带当前时间就可以了
toury 2009-07-16
  • 打赏
  • 举报
回复

<%
function getHTTPPage(byval url)
if instr(url,"?")>0 then
url=url&"&d="&now()
else
url=url&"?d="&now()
end if
dim httpxml
Set httpxml= server.CreateObject("msxml2.XMLHTTP")
httpxml.open "get",url,False
httpxml.send()
if httpxml.readystate<>4 then
exit function
end if
getHTTPPage=bytesToBSTR(Httpxml.responseBody,"GB2312")
set httpxml=nothing
if err.number<>0 then err.Clear
end function ' 2、转换乱玛,直接用xmlhttp调用有中文字符的网页得到的将是乱玛,可以通过adodb.stream组件进行转换
Function BytesToBstr(body,Cset)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
%>
toury 2009-07-16
  • 打赏
  • 举报
回复
让参数url带一时间戳参数
比如:
如果url参数原先就带有?,那就 url=url&"&d="&now()
如果原url不带?,就url=url&"?d="&now()

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧