twitter-bootstrap 修复 Google PageSpeed 的“提供缩放图像”以实现响应式布局
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15133562/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Fix Google PageSpeed's "Serve scaled images" for responsive layout
提问by Howard
My layout is responsive so I need to have scaled images put into the template, e.g. when using mobile devices, the span3of Boostrapmight occupy a full row so the width will be increased.
我的布局是响应式的,所以我需要将缩放的图像放入模板中,例如,当使用移动设备时,span3ofBoostrap可能会占据整行,因此宽度会增加。
But in the Google PageSpeed it is marked as an issue.
但是在 Google PageSpeed 中它被标记为一个问题。
Are there any workaround or a better way to handle this?
有没有解决方法或更好的方法来处理这个问题?
采纳答案by Akshaya Raghuvanshi
Have you enabled compression gzip or deflate mode? It tells us because either we didn't use cache (either browser or proxy). Write this in your header/ .htaccess file.
您是否启用了压缩 gzip 或 deflate 模式?它告诉我们,因为要么我们没有使用缓存(浏览器或代理)。将此写入您的标头/ .htaccess 文件中。
<FilesMatch "\.(ico|jpg|jpeg|png|gif|js|css|swf|svg|pdf|flv|mp3)$">
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 month 2 days 3 hours" //example you can change it
Header set Cache-Control "public"
</IfModule>
</FilesMatch>
And one thing if browser still ignores it. You can also use Adaptive-Imagesmethod to sever your assets as per less DNS look-ups and scaled down for small-devices.
如果浏览器仍然忽略它,还有一件事。您还可以使用Adaptive-Images方法根据较少的 DNS 查找来切断您的资产,并为小型设备缩小规模。
If you use one of those methods, you don't have to worry about images-scaled or not. I have tried all these thingsand got 98out 100Page Speed.
如果您使用其中一种方法,则不必担心图像缩放与否。我已经尝试了所有这些事情,并得到了98出100页的速度。
You can believe if you check out the page speed of this page. Hope you better fix it too.
如果您查看此页面的页面速度,您就会相信。希望你也能更好地修复它。

