在ASP.NET应用程序浏览器缓存 [英] Browser Caching in ASP.NET application

查看:154
本文介绍了在ASP.NET应用程序浏览器缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关如何在asp.net应用程序中做浏览器缓存的任何建议。我发现了一些不同的方法在网上,但不知道什么是最好的。具体来说,我想我的缓存CSS和JS文件。它们做改变,但是,它通常是每月一次至多。

Any suggestions on how to do browser caching within a asp.net application. I've found some different methods online but wasn't sure what would be the best. Specifically, I would like to cache my CSS and JS files. They do change, however, it is usually once a month at the most.

推荐答案

另一种方法是你存储静态图像,CSS和JS另一台服务器上(如的 CDN ),其中有Expires头设置正确。这样做的好处是双重的:

Another technique is to stores you static images, css and js on another server (such as a CDN) which has the Expires header set properly. The advantage of this is two-fold:


  1. Expires头将鼓励浏览器和代理缓存这些静态文件

  2. 的CDN将您的服务器提供静态文件卸载。

  3. 将使用其他域名的静态内容,浏览器会下载速度更快。这是因为从四五个不同的主机名服务资源增加下载并行

  4. 如果CDN的配置正确,并使用<一个href=\"http://$c$c.google.com/speed/page-speed/docs/request.html#ServeFromCookielessDomain\">cookieless域那么你没有不必要的饼干来回。

  1. The expires header will encourage browsers and proxies to cache these static files
  2. The CDN will offload from your server serving up static files.
  3. By using another domain name for your static content, browsers will download faster. This is because serving resources from four or five different hostnames increases parallelization of downloads.
  4. If the CDN is configured properly and uses cookieless domain then you don't have unnecessary cookies going back and forth.

这篇关于在ASP.NET应用程序浏览器缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆