Created
June 24, 2017 07:32
-
-
Save ivmm/a02e59b9c9bc281173763dd8900e644c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# on 启用,off 关闭 | |
pagespeed on; | |
# 重置 http Vary 头 | |
pagespeed RespectVary on; | |
# html字符转小写 | |
pagespeed LowercaseHtmlNames on; | |
# 压缩带 Cache-Control: no-transform 标记的资源 | |
pagespeed DisableRewriteOnNoTransform off; | |
# 相对URL | |
pagespeed PreserveUrlRelativity on; | |
# X-Header 值,用于判断是否生效 | |
pagespeed XHeaderValue "Powered By MF8.BIZ"; | |
# 配置服务器缓存位置和自动清除触发条件(空间大小、时限) | |
pagespeed FileCachePath "/data/ngx_pagespeed/"; | |
pagespeed FileCacheSizeKb 2048000; | |
pagespeed FileCacheCleanIntervalMs 43200000; | |
pagespeed FileCacheInodeLimit 500000; | |
# 过滤规则 | |
pagespeed RewriteLevel PassThrough; | |
# 过滤WordPress的后台(可选配置,可参考使用) | |
pagespeed Disallow "*/wp-admin/*"; | |
pagespeed Disallow "*/wp-login.php*"; | |
# 移除不必要的url前缀,开启可能会导致某些自动加载功能失效 | |
#pagespeed EnableFilters trim_urls; | |
# 移除 html 空白 | |
pagespeed EnableFilters collapse_whitespace; | |
# 移除 html 注释 | |
pagespeed EnableFilters remove_comments; | |
# DNS 预加载 | |
pagespeed EnableFilters insert_dns_prefetch; | |
# 压缩CSS | |
pagespeed EnableFilters rewrite_css; | |
# 合并CSS | |
pagespeed EnableFilters combine_css; | |
# 重写CSS,优化加载渲染页面的CSS规则 | |
pagespeed EnableFilters prioritize_critical_css; | |
# google字体直接写入html 目的是减少浏览器请求和DNS查询 | |
pagespeed EnableFilters inline_google_font_css; | |
# 压缩js | |
pagespeed EnableFilters rewrite_javascript; | |
# 合并js | |
pagespeed EnableFilters combine_javascript; | |
# 优化内嵌样式属性 | |
pagespeed EnableFilters rewrite_style_attributes; | |
# 压缩图片 | |
pagespeed EnableFilters rewrite_images; | |
# 不加载显示区域以外的图片 | |
pagespeed LazyloadImagesAfterOnload off; | |
# 图片预加载 | |
pagespeed EnableFilters inline_preview_images; | |
# 移动端图片自适应重置 | |
pagespeed EnableFilters resize_mobile_images; | |
# 图片延迟加载 | |
pagespeed EnableFilters lazyload_images; | |
# 雪碧图片,图标很多的时候很有用 | |
pagespeed EnableFilters sprite_images; | |
# 扩展缓存 改善页面资源的可缓存性 | |
pagespeed EnableFilters extend_cache; | |
# 将 meta 转换为 header | |
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" { add_header "" ""; } | |
location ~ "^/ngx_pagespeed_static/" { } | |
location ~ "^/ngx_pagespeed_beacon$" { } | |
location /ngx_pagespeed_statistics { allow 127.0.0.1; deny all; } | |
location /ngx_pagespeed_message { allow 127.0.0.1; deny all; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment