2.17.2.1. Site optimization settings (PageSpeed)

Attention!

The use of plugins on the site that perform the same actions as PageSpeed filters can lead to errors in the site. We recommend using one thing - either plugins or PageSpeed.

The site optimization settings use the Google PageSpeed module filters. It is installed on the hosting by default and is designed to speed up the display of the page in the browser. Documentation 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 a page is displayed by a browser, it takes loading its additional elements — images, JavaScript and CSS. Almost all popular CMS themes use JavaScript frameworks with dozens of plugins and lots of CSS styles. The total amount of data uploaded by the 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 by which you can increase the speed of displaying the site in the client browser:

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

You can reduce the number of requests to the server, the amount of data transferred and the efficiency of their compression by combining several files into one and removing unnecessary comments and spaces. If the site has a lot of graphics at the bottom of the pages (which is only visible when scrolling), lazy loading of images can be useful. To speed up page rendering, you need to set up the correct order of including CSS and JavaScript files, and possibly transfer small CSS to HTML code. If the pages actively use elements from other sites (traffic counters, social network widgets, online help chats), pre-resolving the DNS names of these resources can increase their loading speed in modern browsers. This kind of optimization can be done with 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 issues with the PageSpeed module handling content over HTTPS. To fix the situation, you need to remove the redirect directives from .htaccess and instead include the desired redirect in site settings.

Caching allows the browser to keep a copy of the static file on the visitor’s computer and not to ask for it on the server when visiting again. 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 they are used, a hash of their contents is added to the URL of static files, which changes when the file is edited. Thus, long-term caching with the ability to freely make changes is achieved.

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, turning them on one by one and checking the operation 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 merging JavaScript, interactive elements on the site 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 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. Due to the generation of optimized files, the module creates many requests to the server. For the most part, requests are directed to static content and their processing should not cause server load and problems, but in some cases, requests can be directed to content generated by PHP scripts and thus create a large load (this scenario is extremely rare, but it does happen) .
  • 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» enable or disable the options you want and save the changes:
  3. Wait approximately 15-30 minutes for the changes to take effect.

By default, PageSpeed filters that process URLs respect attributes from the HTML4 and HTML5 specifications, as well as some of the common extensions listed in Documentation PageSpeed. If the site uses non-standard attributes for the URL (for example, links to images in <li data-thumb="URL">), you need to explicitly tell PageSpeed to process them.

Attributes are added to the field «Additional attributes with URL value» (be sure to save changes after adding):

Rules for specifying exceptions:

  • The URL must be specified 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 the URLs you want to exclude and save the changes:
  3. Wait approximately 15-30 minutes for the changes to take effect.

Attention!

  • 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 user agent requests pagespeed cache cleaner. For example, the work of such requests in some cases may be interfered with by redirect directives 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» disable all options or enable an option «disabled» («Disable site optimization») and save the changes:
  3. Wait approximately 15-30 minutes for the changes to take effect.
Content