简体   繁体   English

防止某些文件夹在请求标头中附加cookie

[英]Prevent certain folder from attaching cookies in request headers

I have an application built with codeigniter and am running tests for rendering time etc, i have noticed that some certain static files have cookies attached to them which are adding unnecessary loading times. 我有一个使用codeigniter构建的应用程序,并且正在运行渲染时间等测试,我注意到某些静态文件具有附加的cookie,这会增加不必要的加载时间。 I was wondering if it was possible to prevent requests to the folder from attaching cookies to the headers. 我想知道是否有可能防止对文件夹的请求将cookie附加到标题。 my site structure looks like this; 我的网站结构如下:

  • application 应用
  • system 系统
  • assets 资产
  • assets/js 资产/ js
  • assets/css 资产/ CSS
  • assets/img 资产/ img
  • profiles 型材

I dont want requests to the assets and profiles folder to have cookies in their headers 我不希望对资产和配置文件文件夹的请求的标题中包含cookie

If you're setting cookies at the root, you'll need a separate hostname to do this. 如果要在根目录设置cookie,则需要一个单独的主机名来执行此操作。

I wouldn't serve the CSS from a separate hostname though... 我不会从单独的主机名提供CSS ...

After HTML, CSS is the next most important resource on a webpage as browser can't start rendering the page until it has the CSS. 在HTML之后,CSS是网页上的下一个最重要的资源,因为浏览器只有拥有CSS才能开始呈现页面。

If you serve the CSS from a separate domain then there's the overhear of resolving that domain and in some browsers the overhead of TCP connection set up (Chrome, IE9 and possibly other browsers speculatively open a second TCP connection to the host the HTML came from before they know they need it) 如果您从一个单独的域提供CSS,则存在解析该域的行为,在某些浏览器中,TCP连接设置的开销(Chrome,IE9以及可能的其他浏览器以推测的方式打开了与HTML之前的主机的第二个TCP连接)他们知道他们需要它)

The CSS will still have the cookie set on it but if you set a long cache time for it, the CSS should only be requested once per session. CSS仍将设置cookie,但是如果您为其设置了较长的缓存时间,则每个会话仅应请求一次CSS。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM