在请求静态内容时避免Cookie [英] Avoiding cookies while requesting static content

查看:213
本文介绍了在请求静态内容时避免Cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚使用Google Chrome的开发人员工具对我的一个网络应用程序页面(使用ASP.Net构建并在开发服务器上运行)进行了审核。一个特别的警告引起了我的注意:

I just did an audit of one of my web application page (built using ASP.Net and running on development server) using Google chrome's developer tool. One particular warning caught my eyes:

从无Cookie网域提供静态内容(5)

这是我的屏幕截图( http://yfrog.com/7eauditresultp )。我想知道是否有可能避免这些类型的请求的cookie。我看到没有cookie请求的javascript文件以及。我可以避免这些文件的标题中的cookie吗?为什么浏览器不附加JavaScript文件的Cookie并附加CSS和图片?

Here is my screen shot (http://yfrog.com/7eauditresultp) as well. I would like to know is it possible to avoid cookies for these kind of requests. I see that there is no cookie requests for javascript files as well. I it possible to avoid cookies in the header for these files as well? and why didn't the browser attach cookies for javascript files and attach for CSS and image?

欢迎任何想法和建议

推荐答案

Cookie被附加到域和路径。如果您为档案上方的路径设定Cookie,系统会一并传送这些档案的任何要求。

Cookie are "attached" to a domain and a path. If you set cookies for a path above your files, they'll be sent with any request for those files.

警告讯息本身会告诉您如何解决这个问题 - 使用另一个域为您的静态内容。或者是一个子域名,只要您确保在这种情况下保持您的主域无Cookie。

The warning message itself tells you how to fix this - use another domain for your static content. Or a subdomain, as long as you make sure you keep your main domain cookieless in that case.

这篇关于在请求静态内容时避免Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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