我正在尝试使用Nginx和Google的pagespeed mod来消除空格和HTML注释,但它无法正常工作。我在后端运行Tomcat 8。我们可以在日志文件中看到Netsx正在加载pagespeed。以下是我的conf文件。任何想法为什么它不起作用?
server {
pagespeed on;
pagespeed EnableFilters remove_comments;
pagespeed EnableFilters collapse_whitespace;
pagespeed FileCachePath /run/shm/pagespeed_cache;
pagespeed RewriteLevel CoreFilters;
#pagespeed RespectVary on; #Respecting Vary Headers
#pagespeed DisableRewriteOnNoTransform off; #Honoring no-transform Cache-Control Headers
#pagespeed LowercaseHtmlNames on; #Lower-casing HTML element and attribute names
#pagespeed ModifyCachingHeaders off; #Preserving HTML caching headers
#pagespeed XHeaderValue "Powered By ngx_pagespeed"; #Specifying the value for the PageSpeed header
#pagespeed StaticAssetPrefix /custom/static/; #Configuring the location of static assets
#pagespeed PreserveUrlRelativity on; #Preserve URL Relativity
listen 80 default_server;
listen [::]:80 default_server;
server_name mysite.org www.mysite.org;
return 301 https://$server_name$request_uri;
}
答案 0 :(得分:0)
您在问题中显示的服务器块无法处理任何实际的HTML内容,因为它只是通过return 301 https://$server_name$request_uri;
- 指令重定向到https。同时在https服务器块中启用pagespeed模块。