|
pagespeed on; |
|
|
|
# Needs to exist and be writable by nginx. Use tmpfs for best performance. |
|
pagespeed FileCachePath /tmp/; |
|
|
|
# All servers running a given release will have the same value for this header by default. |
|
# If you would like to change the value reported, you can use the XHeaderValue directive to specify what to use instead: |
|
pagespeed XHeaderValue "Powered by ngx_pagespeed"; |
|
|
|
# With PreserveUrlRelativity on, PageSpeed will keep URLs the way they were found. |
|
pagespeed PreserveUrlRelativity on; |
|
|
|
# HTML is case-insensitive, whereas XML and XHTML are not. Web performance Best Practices |
|
# suggest using lowercase keywords, and PageSpeed can safely make that transformation in HTML documents. |
|
pagespeed LowercaseHtmlNames on; |
|
pagespeed AvoidRenamingIntrospectiveJavascript off; |
|
|
|
# You can specify the maximum length (in bytes) of the content for PageSpeed to optimize. |
|
# A setting of -1 means content of all lengths will be optimized, but risks server out-of-memory crashes. |
|
pagespeed MaxCacheableContentLength -1; |
|
|
|
# By using the CoreFilters set, as PageSpeed is updated with new filters, your site will get faster. |
|
pagespeed RewriteLevel CoreFilters; |
|
|
|
# If your site uses a non-standard attribute for URLs, PageSpeed won't know to rewrite them or the |
|
# resources they reference. To identify them to PageSpeed, use the UrlValuedAttribute directive. |
|
pagespeed UrlValuedAttribute img data-src image; |
|
|
|
# By default, PageSpeed serves all HTML with Cache-Control: no-cache, max-age=0 because the |
|
# transformations made to the page may not be cacheable for extended periods of time. |
|
# pagespeed ModifyCachingHeaders off; |
|
# pagespeed UseExperimentalJsMinifier on; |
|
|
|
# Optimizations |
|
## region CSS |
|
|
|
### Inlines small CSS files into the HTML document. |
|
pagespeed EnableFilters inline_css; |
|
|
|
### Combines multiple CSS elements into one. |
|
pagespeed EnableFilters combine_css; |
|
|
|
### Moves CSS elements above <script> tags. |
|
pagespeed EnableFilters move_css_above_scripts; |
|
|
|
### Replace CSS tags with inline versions that include only the CSS used by the page. |
|
pagespeed EnableFilters prioritize_critical_css; |
|
|
|
### Rewrites CSS files to remove excess whitespace and comments, and, if enabled, rewrite or |
|
### cache-extend images referenced in CSS files. In OptimizeForBandwidth mode, the minification |
|
### occurs in-place without changing URLs. |
|
pagespeed EnableFilters rewrite_css; |
|
|
|
### Rewrite the CSS in style attributes by applying the configured rewrite_css filter to it. |
|
pagespeed EnableFilters rewrite_style_attributes; |
|
|
|
### Externalize large blocks of CSS into a cacheable file. |
|
pagespeed EnableFilters outline_css; |
|
|
|
### Moves CSS elements into the <head>. |
|
pagespeed EnableFilters move_css_to_head; |
|
|
|
### Rewrites resources referenced in any CSS file that cannot otherwise be parsed and minified. |
|
pagespeed EnableFilters fallback_rewrite_css_urls; |
|
## endregion |
|
|
|
## region JS |
|
|
|
### Convert synchronous use of Google Analytics API to asynchronous |
|
pagespeed EnableFilters make_google_analytics_async; |
|
|
|
### Externalize large blocks of JS into a cacheable file. |
|
pagespeed EnableFilters outline_javascript; |
|
|
|
### Adds source maps to rewritten JavaScript files. |
|
pagespeed EnableFilters include_js_source_maps; |
|
|
|
### Redirects JavaScript libraries to a JavaScript hosting service. |
|
pagespeed EnableFilters canonicalize_javascript_libraries; |
|
|
|
### Cache inlined resources in HTML5 local storage. |
|
pagespeed EnableFilters local_storage_cache; |
|
|
|
### Inlines small JS files into the HTML document. |
|
pagespeed EnableFilters inline_javascript; |
|
|
|
### Defers the execution of JavaScript in HTML until page load complete. |
|
# pagespeed EnableFilters defer_javascript; |
|
### Combines multiple script elements into one. |
|
# pagespeed EnableFilters combine_javascript; |
|
### Rewrites JavaScript files to remove excess whitespace and comments. |
|
### In OptimizeForBandwidth mode, the minification occurs in-place without changing URLs. |
|
# pagespeed EnableFilters rewrite_javascript; |
|
## endregion |
|
|
|
## region Images |
|
|
|
### Works just like inline_preview_images, but uses smaller placeholder images and only serves them to mobile browsers. |
|
pagespeed EnableFilters resize_mobile_images; |
|
|
|
### Loads images when they become visible in the client viewport. |
|
pagespeed EnableFilters lazyload_images; |
|
|
|
### Adds width and height attributes to <img> tags that lack them. |
|
pagespeed EnableFilters insert_image_dimensions; |
|
|
|
### Replaces repeated inlined images with JavaScript that loads the image from the first occurence of the image. |
|
pagespeed EnableFilters dedup_inlined_images; |
|
|
|
### Uses inlined low-quality images as placeholders which will be replaced with original images once the web page is loaded. |
|
# pagespeed EnableFilters inline_preview_images; |
|
### Implied by rewrite_images. Replaces png and non-animated gif images with webp images on browsers that support the format. |
|
# pagespeed EnableFilters convert_to_webp_lossless; |
|
### Combine background images in CSS files into one sprite. |
|
# pagespeed EnableFilters sprite_images; |
|
### Optimizes images, re-encoding them, removing excess pixels, and inlining small images. |
|
### In OptimizeForBandwidth mode, the minification occurs in-place without changing URLs. |
|
# pagespeed EnableFilters rewrite_images; |
|
### Makes images responsive by adding srcset with images optimized for various resolutions. |
|
# pagespeed EnableFilters responsive_images; |
|
### Implied by rewrite_images. Resizes images when the corresponding <img> tag specifies a smaller width and height. |
|
# pagespeed EnableFilters resize_images; |
|
## endregion |
|
|
|
## region HTML |
|
|
|
### Removes excess whitespace in HTML files (avoiding <pre>, <script>, <style>, and <textarea>). |
|
pagespeed EnableFilters collapse_whitespace; |
|
|
|
### Removes comments in HTML files (but not in inline JavaScript or CSS). |
|
pagespeed EnableFilters remove_comments; |
|
|
|
### Removes quotes around HTML attributes that are not lexically required. |
|
pagespeed EnableFilters remove_quotes; |
|
|
|
### Shortens URLs by making them relative to the base URL. |
|
### !!! can't use it as it will trim the _path urls and that won't be good. |
|
# pagespeed EnableFilters trim_urls; |
|
|
|
### Add default types for <script> and <style> tags if the type attribute is not present and the |
|
### page is not HTML5. The purpose of this filter is to help ensure that PageSpeed does not break HTML4 validation. |
|
pagespeed EnableFilters pedantic; |
|
|
|
### Perform browser-dependent in-place resource optimizations. (https://www.modpagespeed.com/doc/system#ipro) |
|
pagespeed EnableFilters in_place_optimize_for_browser; |
|
|
|
### Inserts <link rel="dns-prefetch" href="//www.example.com"> tags to reduce DNS resolution time. |
|
pagespeed EnableFilters insert_dns_prefetch; |
|
|
|
### Extends cache lifetime of CSS, JS, and image resources that have not otherwise been optimized, by signing URLs with a content hash. |
|
pagespeed EnableFilters extend_cache; |
|
## endregion |
|
|
|
## region Authorization |
|
pagespeed Domain *.epicpxls.com; |
|
pagespeed Domain localhost; |
|
## endregion |
|
|
|
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" { |
|
add_header "" ""; |
|
} |
|
|
|
location ~ "^/pagespeed_static/" { } |
|
location ~ "^/ngx_pagespeed_beacon$" { } |