PageSpeed site optimization trouble

半世苍凉 提交于 2019-12-25 06:51:31

问题


I have a problem with the inclusion of compression on my website. Site hosted with WordPress and GZIP compression of HTML works fine even without any lines in the .htaccess or plug-ins. But the compression of JS/CSS does not turn on. Ive tried a lot of different codes, such as:

<IfModule mod_deflate.c>
<FilesMatch "\.(html|php|txt|xml|js|css)$">
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>

or

AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

or

# compress all text and html:
AddOutputFilterByType DEFLATE text/css application/javascript

or

# Or, compress certain file types by extension:
<Files *.css>
SetOutputFilter DEFLATE
</Files>
<Files *.js>
SetOutputFilter DEFLATE
</Files>

or even in my header.php:

<?php ob_start("ob_gzhandler"); ?> //result - site crahes

and many others....

Communicated with the server administrator, included more apache modificators: mod_headers, mod_filter and mod_expires, but compression still does not work. I can not understand why??? And how compression of HTML works???

Some of my server's phpinfo():

PHP Version 5.3.3-7+squeeze14
Apache Version  Apache/2.2.16 (Debian)
Loaded Modules  mod_deflate mod_expires mod_filter mod_headers mod_include mod_mime mod_rewrite etc...
HTTP_ACCEPT_ENCODING    gzip,deflate,sdch
Accept-Encoding gzip,deflate,sdch

I've tried to use a lot of WP plugins, such as: W3 Total Cache, Force GZIP, WP HTTP compression, etc... And... Nothing!

Then I've tried to compress files manually: style.css -> style.css.gz -rename-> style.css -load to ftp and replace original. Google's PageSpeed says "Great! Compression enabled! Here is your speed points", but my browser says "Where is my style.css and what kind of cr*p is this?" - because response with style.css has no "encoded gsip" header.

Thanks for advise!!!


回答1:


The solution is quite simple. Problem is in apache configuration: AllowOverride directive.

AllowOverride None

must be changed to:

AllowOverride AuthConfig FileInfo

or just AllowOverride All

Then, if you want to optimize browser cache

leverage browser caching

and set ExpiresActive on, config your HTTPD.conf to:

AllowOverride AuthConfig FileInfo Indexes

or just AllowOverride All

The question is, will the hosting administrator account change the settings.....



来源:https://stackoverflow.com/questions/18632081/pagespeed-site-optimization-trouble

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!