当 CSS 被 gzip 压缩时,它不起作用
我想对我的 css 样式表进行 gzip 压缩。我将其链接为外部样式表。
这里:http://illution.dk
这是样式表: http://illution.dk/include/style.css
它是压缩的: http://www.whatsmyip.org/http_compression/?url=aHR0cDovL2lsbHV0aW9uLmRrL2luY2x1ZGUvc3R5bGUuY3Nz
我的问题是它似乎不起作用。我做错了什么吗?
更新:我发现我只需要添加“header(”Content-type: text/css”);”到我的css文档中就可以了:D!
I my css stylesheet that i want to gzip. I have it linked as a external stylesheet.
Here: http://illution.dk
And this is the stylesheet: http://illution.dk/include/style.css
And it IS gzipped: http://www.whatsmyip.org/http_compression/?url=aHR0cDovL2lsbHV0aW9uLmRrL2luY2x1ZGUvc3R5bGUuY3Nz
My problem is that it doesn't seem to work. Am i doing something wrong?
UPDATE: I found out that i just needed to add "header("Content-type: text/css"); " to my css document and it just worked :D!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如我在这里检查的那样,CSS 似乎是有效的: W3C CSS Validator,它在 Chrome 上看起来很适合我。不过,我确实在 Chrome 开发者工具中看到了一条警告:
看来您的服务器没有正确设置 CSS 文件的 MIME 类型。
The CSS appears to be valid as I checked here: W3C CSS Validator and it looks right for me on Chrome. However, I did see a warning in the Chrome Developer tools:
It appears your server isn't properly setting the MIME type for CSS files.