2012-02-22 60 views
2

我有一個經典的ASP頁面,使用服務器端包含在其他一些ASP文件中調用。防止服務器端包含文件的緩存

我不想要任何瀏覽器緩存主文件或包含的文件。

目前我的主要看起來是這樣的:

<%@ Language="VBSCRIPT" %><% Option Explicit %> 
<% 
Response.CacheControl = "no-cache" 
Response.AddHeader "Pragma", "no-cache" 
Response.Expires=-1 
%> 
<!--#include file="scripts1.asp"--> 
<!--#include file="scripts2.asp"--> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>myTitle</title> 
<!--#include file="head.asp"--> 
</head> 
<body> 
<!--#include file="body.asp"--> 
</body> 
</html> 

我只放在主頁上,而不是包含文件的Response.CacheControl,Response.AddHeader,Response.Expires代碼。

我的問題是:

  1. 是否所有的服務器端包含的ASP頁面需要Response.CacheControlResponse.AddHeader和我用Response.Expires代碼,或者只是主文件?

  2. 我用過的代碼是否足以防止在所有瀏覽器上緩存?

回答

4

只有「主」輸出頁面需要標題,如您所示。服務器端包含在服務器內部發生,所以瀏覽器從不會看到它。

你做得對。