2.19.1. Site optimization settings (PageSpeed)

Warning!

If the site uses plugins that perform the same actions as the included optimization filters, then this can lead to errors in the site itself. You should either disable plugins or PageSpeed optimization filters.

The site optimization settings use the filters of the Google PageSpeed module. It is installed on the hosting by default and is designed to speed up the display of the page in the browser. The documentation for this module is available at official website.

Site speed is one of the most important factors that modern visitors pay attention to. Site display delays are annoying, negatively impact search engine rankings, and reduce revenue for commercial sites. From the point of view of the visitor, the speed of the site is influenced by two main parameters: the speed of page formation on the server and the speed at which the page is displayed by the browser. To speed up the formation of pages on servers, we use modern equipment and fine—tuning the software. Also, our clients have access to tools that allow us to speed up the speed of displaying the page in the visitor's browser, just by making changes to the settings of their site.

Most of the time when the browser displays the page, it takes up loading additional page elements — images, JavaScript, and CSS... Almost all design themes of popular CMS use a JavaScript framework with a dozen plugins and many CSS-styles. In this case, the total amount of data downloaded by a visitor often exceeds 500 KB, and the number of requests to the server to display one page is several dozen. This negatively affects the page loading speed of the visitor.

There are several techniques that can be used to increase the speed of displaying the site in the client's browser:

  1. Reduce the amount of transmitted data.
  2. Reduce the number of requests to the server.
  3. Configure caching of static files in the browser.
  4. Optimize page rendering.

You can reduce the number of requests to the server, the amount of transmitted data and the efficiency of their compression by combining several files into one and removing unnecessary comments and spaces. If your site has a lot of graphics at the bottom of the pages (which is visible only when scrolling), lazy loading of images can be useful. To speed up page rendering, you need to configure the correct connection order CSS- and JavaScript files, and possibly transfer small CSS in HTML-code. If the pages actively use elements from other sites (traffic counters, social media widgets, online help chats), preliminary resolution DNS-names of these resources can improve their loading speed in modern browsers. You can perform this kind of optimizations using PageSpeed settings... All optimizations are performed "on the fly", without the need to make changes to the site code.

The PageSpeed module also works over the HTTPS protocol. When the site is configured redirect from HTTP to HTTPS (or vice versa) using .htaccess, there may be problems with the processing of content by the PageSpeed module over HTTPS. To fix the situation, you need to remove the redirect directives from .htaccess and instead enable the required redirect in the site settings.

Caching allows the browser to save a copy of the static file on the visitor's computer and not contact the server for it on a second visit. However, this creates inconvenience for developers, since visitors will see changes in these files with a delay for the duration of the cache. To avoid this problem, PageSpeed provides advanced caching options for images, styles, and scripts. If used in URL static files, a hash of their content is added, which changes when the file is edited. Thus, long-term caching is achieved with the ability to freely make changes.

Important points:

  • There is no one-size-fits-all set of settings that fits all sites, without exception. Options need to be selected individually for a specific site. For some sites, they may not be needed at all, if the programmers have implemented the corresponding functionality in the engine, for others, only a part of the parameters may be needed.
  • You can determine the settings suitable for the site experimentally, one by one including them and checking the work of the site at each stage. Some of the settings may interfere with the normal operation of the site. For example, after enabling minification or JavaScript merging on the site, interactive elements may stop working (any buttons will not be pressed). This means that the setting is incompatible with this site. In this case, it should be disabled by unchecking the checkbox, and clear cache PageSpeed.
  • The effectiveness of the settings directly depends on how the site developers approached its optimization. For an initially well-optimized site, customizations may be overkill.
  • Some PageSpeed filters can create additional load on the server. By generating optimized files, the module creates many requests to the server. For the most part, requests are aimed at static content and their processing should not cause a load on the server and problems, but in some cases requests can be directed to the generated content by PHP scripts and thereby create a large load (such a scenario is extremely rare, but it takes place) ...
  • PageSpeed optimization filters do not modify files on the server, so after them disconnections the site will return to its previous state.
  • The PageSpeed module has some nuances of work. You can familiarize yourself with them in the documentation at official website.
  • Some merge units have a MaxBytes limit that will not merge files beyond this size. On hosting, the MaxBytes value is 1 KB.
  1. Openup site settings.
  2. In the tab "Site optimization settings" check or uncheck the boxes next to the required options and click "Save":
  3. Wait approximately 15-30 minutes for the changes to take effect.

Rules for specifying exceptions:

  • URL you need to specify without the name of the site itself, for example */jquery.js or */static*.
  • Directories must be framed with two characters *, for example */content*.
  • Each exception is listed on a new line.
  • One exception must not exceed 100 characters in length.
  • Available symbols: a-z 0-9 - . _ / *.
  1. Openup site settings.
  2. In the tab "Site optimization settings" in field "Exceptions from PageSpeed" enter URLto exclude and click "Save":
  3. Wait approximately 15-30 minutes for the changes to take effect.

Warning!

  • To clear the PageSpeed cache, a special request is sent to the site. If you get an error while clearing the cache, check in access logs server response codes for requests with the pagespeed cache cleaner user agent. For example, the work of such requests in some cases can interfere with the directives of redirects from the file .htaccess... In such a situation, the solution may be to temporarily rename this file while clearing the cache.
  • The clear cache button is only displayed when enabled optimization settings. If optimization or all of its options are disabled, the button will not be displayed.
  1. Openup site settings.
  2. In the tab "Site optimization settings" at the bottom of the page click "Clear cache":
  1. Openup site settings.
  2. In the tab "Site optimization settings" uncheck all the options or check the box next to the option "disabled" ("Disable site optimization") and press "Save":
  3. Wait approximately 15-30 minutes for the changes to take effect.
Content