我在想,为了提高网站的速度,采取一些策略来缓存正在包含的 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();
}
并在 site.master 上:
<%=Html.RenderAction("JQuery","JsController");
最佳答案
那不是必须的。您可以在 web.config 和 IIS 上为 JS(和任何静态文件)指定缓存策略。
特别是对于 jQuery,您可以从 google CDN 引用该库。
关于javascript - asp.net-mvc:javascript 缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2904782/