启用 Google minify 后,从缓存加载的任何内容都会被破坏

发布于 2024-11-19 04:15:30 字数 2320 浏览 5 评论 0原文

我已在我们网站上使用此库在代码点火器中启用了 google Minify。

当您第一次查看使用通过压缩器运行的文件(css 或 js)的页面时,一切都会正常加载。

但是,下次加载页面时,文件不会加载。如果您执行 ctrl+f5 ,则页面加载正常,但再次,下次它会损坏。

直接查看文件时,您将获得内容,或者随机收到 416“请求的范围无法满足”错误。

我不知道如何开始追踪这个问题的原因。

有人有什么想法吗?

正确加载的文件的标头

Request URL:http://unity.nz.local/css/global.css
Request Method:GET
Status Code:200 OK
Request Headers
Accept:text/css,*/\*;q=0.1
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8,en-NZ;q=0.6
Cache-Control:no-cache
Connection:keep-alive
Cookie:ci_unity=[removed]
Host:unity.nz.local
Pragma:no-cache
Referer:http://unity.nz.local/
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30

Response Headers
Cache-Control:max-age=2419200, public
Connection:Keep-Alive
Content-Encoding:gzip
Content-Length:8884
Content-Type:text/css; charset=utf-8
Date:Fri, 08 Jul 2011 03:10:52 GMT
Expires:Fri, 05 Aug 2011 03:10:52 GMT
Keep-Alive:timeout=15, max=69
Last-Modified:Thu, 07 Jul 2011 22:39:10 GMT
Server:Apache/2.2.17 (Ubuntu)
Vary:Accept-Encoding
X-Powered-By:PHP/5.3.5-1ubuntu7.2

第二次加载时的标头

Request Method:GET
Status Code:200 OK
Request Headers
Accept:text/css,*/\*;q=0.1
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8,en-NZ;q=0.6
Cache-Control:max-age=0
Connection:keep-alive
Cookie:ci_unity=[removed]
Host:unity.nz.local
If-Modified-Since:Thu, 07 Jul 2011 22:39:10 GMT
Referer:http://unity.nz.local/
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30

Response Headers
Cache-Control:max-age=2419200, public
Connection:Keep-Alive
Content-Encoding:gzip
Content-Length:20
Content-Type:text/html
Date:Fri, 08 Jul 2011 03:13:52 GMT
Expires:Fri, 05 Aug 2011 03:13:52 GMT
Keep-Alive:timeout=15, max=69
Last-Modified:Thu, 07 Jul 2011 22:39:10 GMT
Server:Apache/2.2.17 (Ubuntu)
Vary:Accept-Encoding
X-Powered-By:PHP/5.3.5-1ubuntu7.2
_responseCode:HTTP/1.0 304 Not Modified

另请注意,正在创建缓存文件(尽管它们具有只读权限)。并且里面的内容是正确的。我注意到的一件事是,既存在该文件,又创建了一个包含相同文件的 .gz 文件。

I have enabled google Minify in code igniter using this library on our website.

When you first view a page that uses a file (css or js) run through the minifier everything loads fine.

However the next time you load the page the files don't load. if you do a ctrl+f5 then the page loads fine, but again, the next time it is broken.

When viewing the file directly you will either get the content, or randomly get a 416 "requested range not satisfiable" error.

I have no idea how to start tracking down the cause of this issue.

Anyone have any ideas?

Header of properly loaded file

Request URL:http://unity.nz.local/css/global.css
Request Method:GET
Status Code:200 OK
Request Headers
Accept:text/css,*/\*;q=0.1
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8,en-NZ;q=0.6
Cache-Control:no-cache
Connection:keep-alive
Cookie:ci_unity=[removed]
Host:unity.nz.local
Pragma:no-cache
Referer:http://unity.nz.local/
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30

Response Headers
Cache-Control:max-age=2419200, public
Connection:Keep-Alive
Content-Encoding:gzip
Content-Length:8884
Content-Type:text/css; charset=utf-8
Date:Fri, 08 Jul 2011 03:10:52 GMT
Expires:Fri, 05 Aug 2011 03:10:52 GMT
Keep-Alive:timeout=15, max=69
Last-Modified:Thu, 07 Jul 2011 22:39:10 GMT
Server:Apache/2.2.17 (Ubuntu)
Vary:Accept-Encoding
X-Powered-By:PHP/5.3.5-1ubuntu7.2

Headers on second load

Request Method:GET
Status Code:200 OK
Request Headers
Accept:text/css,*/\*;q=0.1
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8,en-NZ;q=0.6
Cache-Control:max-age=0
Connection:keep-alive
Cookie:ci_unity=[removed]
Host:unity.nz.local
If-Modified-Since:Thu, 07 Jul 2011 22:39:10 GMT
Referer:http://unity.nz.local/
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30

Response Headers
Cache-Control:max-age=2419200, public
Connection:Keep-Alive
Content-Encoding:gzip
Content-Length:20
Content-Type:text/html
Date:Fri, 08 Jul 2011 03:13:52 GMT
Expires:Fri, 05 Aug 2011 03:13:52 GMT
Keep-Alive:timeout=15, max=69
Last-Modified:Thu, 07 Jul 2011 22:39:10 GMT
Server:Apache/2.2.17 (Ubuntu)
Vary:Accept-Encoding
X-Powered-By:PHP/5.3.5-1ubuntu7.2
_responseCode:HTTP/1.0 304 Not Modified

Also note that the cache files are being created, (although they have a read-only permission). and the content inside them is correct. one thing i did notice is that there is both the file, and a .gz with the same file inside created.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

衣神在巴黎 2024-11-26 04:15:30

我以前有过这样的经历。这最终部分是 Apache 配置问题,部分是浏览器期望 gzip 压缩的文件应以 .gz 结尾。您正在发送正确的 Content-Encoding 响应标头,因此我会先尝试其他操作。

I've had this experience before. It ended up being partly an Apache configuration issue, and partly a browser expectation that gzipped files should end in .gz. You're sending the right Content-Encoding response header, so I'd try the other thing first.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文