Omu*_*Omu 3 javascript asp.net-mvc caching
我想是否有必要为了提高网站的速度来做一些缓存正在包含的js文件的策略?
我有一个想法是做这样的事情:
[OutputCache(Location = OutputCacheLocation.Any, Duration = 3600)]
public JsController : Controller
public ActionResult JQuery()
{
//I would have a ascx with the entire jquery script inside
return View();
}
Run Code Online (Sandbox Code Playgroud)
并在site.master上:
<%=Html.RenderAction("JQuery","JsController");
Run Code Online (Sandbox Code Playgroud)
这不是必要的.您可以在web.config和IIS上为JS(以及任何静态文件)指定缓存策略.
特别是对于jQuery,您可以从谷歌CDN引用该库.
http://code.google.com/apis/ajaxlibs/documentation/#jquery