cache 를 이용 하여 정적 페이지 를 비교 하 는 웹 기술

정적 페이지 를 만 드 는 글 시스템 을 쓰 고 싶 었 습 니 다. 그러나 정적 을 생 성 한 후의 복잡 한 데이터베이스 상호작용 문제 에 직면 했다.또 뒷걸음질 쳐!그래서 있다 없다 데이터 상호작용 을 지체 하지 않 고 서버 부담 을 줄 일 수 있 는 방법 은?한 사이트 에서 방 문 량 이 가장 많은 것 은 첫 페이지 홈 페이지 랑 요. 다른 페이지 생각 하지 않 아 도 되 는데, 홈 페이지 와 홈 페이지 빅 데이터 에서 서버 변경 은 어떻게 감당 합 니까?제 가 2 년 넘 게 프로 그래 밍 한 경험 에 의 하면 방법 을 찾 아 보고 싶 었 어 요!정적 페이지 생 성 안 함 그리고 서버 부담 감소!.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
'
Public Function readRemoteFile(RemoteDataUrl)
    Dim XMLHttp
    'On Error Resume Next
    Set XMLHttp = Server.CreateObject("Microsoft.XMLHTTP")
        With XMLHttp
            .Open "Get", RemoteDataUrl, False
            .Send
            readRemoteFile = BytesToBstr(.responseBody, "UTF-8")
        End With
    Set XMLHttp = Nothing   
End Function
'
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

Function tobody()
    Dim dateVal
                ' , ,
    dateVal = Application("defaultdate")
    If dateVal = "" Then dateVal = DateAdd("s",1200,Now)
    If Application("default") <> "" Then
        If DateDiff("s", Now, dateVal) > 0 Then
                                                ' , , ,
            tobody = Application("default")&"<!--new cache"&dateVal&"-->"
            Exit Function
        End If
    End If
    Dim body
                ' , , , 。
    body = readRemoteFile("http://www.aoaob.com/default.asp")
    tobody = body&"<!--made cache"&Now&"-->"
    Application.Lock
    Application("default") = body
    Application("defaultdate") = DateAdd("s",1200,Now)
    Application.UnLock
End Function
Response.Write(tobody())
%>

좋은 웹페이지 즐겨찾기