0

Google PageSpeed ​​module configuration

Published by Mihai Bobriuc on 2020-Sep-17
This article will present the method for selectively enabling or disabling PageSpeed ​​filters, related to the additional SEO hosting option.
Tutorials Technical PageSpeed • Google • SEO • ModPageSpeed • htaccess • optimization • apache • pagespeed_module

Introduction

  • If activating the additional SEO option and by default the Google PageSpeed ​​module will create unwanted differences within the site, either visually or in terms of functionality, the various components of the module can be selectively deactivated by editing the .htaccess file. .

Requirements

  • Control panel access data (Plesk or cPanel) for editing the .htaccess file through File Manager.

Steps

  • To check if the PageSpeed ​​module is responsible for the problem encountered, you can disable the entire module by adding the following line to the .htaccess file in the site's root directory:


ModPagespeed off

  • After this step, if the site loads correctly, then the lines added above will be deleted and the specific item responsible for the wrong display will be identified.
  • A first step would be to check the errors received when loading the page by accessing it with Developer Mode in the browser, the general shortcut for activation being F12 key for the usual browsers. For example, a loading error for JS or CSS will indicate a possible conflict with PageSpeed ​​filters, which interact with these elements.

To disable a specific filter, the following rule will be added to the .htaccess file:


ModPagespeedDisableFilters name_filter

Where name_filter will be replaced with the desired identifier.

  • Alternatively, the operation mode of PageSpeed ​​can be changed, so that you can selectively activate each desired element by setting:


ModPagespeedRewriteLevel PassThrough

And then, the desired elements will be specified for activation, as follows:

ModPagespeedEnableFilters name_filter

Also, the name_filter will be replaced with the desired identifier.

  • You can also create a .htaccess file with these rules, in a subdirectory, which contains stylizations (CSS, Javascript, HTML). In this way, the preferential rules will apply strictly to that subdirectory
  • The default active elements when activating the additional SEO option are:
    *These are also the identifiers that you can use in the .htaccess rules.
    • add_head
      Adds a type element to the document if it does not already exist.
    • combine_css
      Combines multiple CSS elements into one.
    • combine_javascript
      Combines multiple JavaScrip elements into one.
    • remove_comments
      Delete comments from processed HTML files. But no inline CSS or JavaScript comments.
    • sprite_images
      Combine CSS wallpapers into a single Sprite.
    • collapse_whitespace
      Delete the empty spaces in HTML files, and ignores the tags: "pre, script, style, textarea"
    • lazyload_images
      Upload images only when they become visible within the page.
    • convert_meta_tags
      Adds a "response header" for each "meta" tag with an attribute "HTTP-equiv".
    • extend_cache
      Extends cache time for images, CSS elements, and scripts that have not been optimized by signing URL with a content hash.
      The following filters are active by default if extend cache is turned on:
      extend_cache_css
      extend_cache_images
      extend_cache_scripts
      For a higher level of control, the filters mentioned above can be activated individually
    • fallback_rewrite_css_urls
      Rewrites URLs for resources that could not be minimized or processed from CSS files.
    • flatten_css_imports
      Recursively replace each @import, rule with the contents of the imported CSS file to reduce the number of external requests.
    • inline_css
      Add small external CSS resources to the HTML document in inline form.
    • inline_import_to_link
      Transform "style" tags that contain only CSS @import to equivalent "link" tags
    • inline_javascript
      Rewrites small JS resources as inlines in the HTML document.
    • rewrite_css
      Rewrite CSS files to remove comments and excess free space.
    • rewrite_images
      Optimize images by editing and removing extra pixels.
      Also, add small images as inline to the document.
    • rewrite_javascript
      Rewrites JavaScript files, removes excess free space and comments.
    • rewrite_style_attributes_with_url
      Rewrite CSS from Style attributes if it contains the text "URL" using the configured rewrite_css filter.
!

If after reading and following the steps outlined in the article you are unable to successfully complete the described task or action, or if you have additional questions or concerns please do not hesitate to contact Hostico.

!
pixel
AwesomeChat by Hostico
×

Hostico utilizes, collects and processes cookies for portal functionality, security, analytics and user experience improvements.

more details