无码国产精成人午夜视频不卡,久久久无码精品亚洲日韩蜜桃 ,国产亚洲欧美日韩在线一区 ,狠狠色丁香婷婷综合久久来来去

新聞建站cms系統(tǒng)、政府cms系統(tǒng)定制開(kāi)發(fā)

廣州網(wǎng)站建設(shè)公司-閱速公司

asp.net新聞發(fā)布系統(tǒng)、報(bào)紙數(shù)字報(bào)系統(tǒng)方案
/
http://www.szzsmy888.com/
廣州網(wǎng)站建設(shè)公司
您當(dāng)前位置:首頁(yè)>網(wǎng)站技術(shù)

網(wǎng)站技術(shù)

如何對(duì)蜘蛛機(jī)器人添加緩存,OutputCache應(yīng)該如何寫(xiě)緩存?

發(fā)布時(shí)間:2013/11/28 12:12:39  作者:Admin  閱讀:356  

廣告:

如何對(duì)蜘蛛機(jī)器人添加緩存,OutputCache應(yīng)該如何寫(xiě)緩存?

ASP.NET MVC Prevent OutputCache if request is from a spider

[OutputCache(Duration = 7200, VaryByParam = "none")]

如何對(duì)蜘蛛機(jī)器人添加緩存,應(yīng)該如何寫(xiě)緩存?

網(wǎng)站首頁(yè)被設(shè)置對(duì)任何請(qǐng)求是一樣的緩存。這里有個(gè)問(wèn)題,如果是正常用戶(hù)訪問(wèn),網(wǎng)站則是正常的,如果第一次請(qǐng)求是從蜘蛛發(fā)起的,則情況不一樣了,網(wǎng)站首頁(yè)變成下載的頁(yè)面了 。

step 1. Load page with normal user agent. (Output cache caches the URL)

step 2. Load page with spider user agent. (the previous cached response is sent to the spider, and my Phantom JS filter never runs)

第一步:正常用戶(hù)客戶(hù)端,輸出緩存正常

第二步:蜘蛛機(jī)器人客戶(hù)端,緩存輸出是針對(duì)蜘蛛客戶(hù)端的。則首頁(yè)正常用戶(hù)訪問(wèn)變成了下載。

解決方法:

Use VaryByCustom to force a 'Cache Miss' when the request is from a Search Engine Crawler(搜索引擎爬蟲(chóng)).

In your Controller/Action:

[OutputCache(VaryByCustom="Crawler")]

public ActionResult Index()

{

// ...

return View();

}

Then in your Global.asax:

public override string GetVaryByCustomString(HttpContext context, string arg)

{

if (arg == "Crawler" && context.Request.Browser.Crawler)

return Guid.NewGuid().ToString();

return base.GetVaryByCustomString(context, arg);

}

廣告:

相關(guān)文章
OutputCache
蜘蛛
cms新聞系統(tǒng)購(gòu)買(mǎi)咨詢(xún)
掃描關(guān)注 廣州閱速軟件科技有限公司
掃描關(guān)注 廣州閱速科技