将无 cookie 域与子域一起使用

Use cookie-free domains with subdomain

想了很久还是想不通

我有我的域名www.bragdeal.com 我创建了一个子域 static.bragdeal.com 并将其指向根

中的文件夹 'static'

我把我所有的图片都放在了 bragdeal.com/static/ 文件夹中 当我 运行 gtmetrix 时,它告诉我 Use cookie-free domains

在我的网站上,我指向这样的图片:

<img src="static/test.jpg">

在我的 htaccess 中我有:

# 1 WEEK
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>

# 1 WEEK
<FilesMatch "\.(xml|txt)$">
Header set Cache-Control "max-age=604800, public, must-revalidate"
</FilesMatch>

# 1 WEEK
<FilesMatch "\.(html|htm|php|js)$">
Header set Cache-Control "max-age=604800, must-revalidate"
</FilesMatch>

我唯一的解决方案是购买一个全新的域来存储我所有的静态内容吗?

您需要使用您创建的子域指向您的图片。 <img src="http://static.bragdeal.com/test.jpg"> 另一种选择是将它们放在 Amazon S3 上——这也会减少一些到您服务器的流量。