2cPanel Blog

This is the place where we share our online experiences, life at work and contents we think our customers might consider helpful and useful. Please visit us often for daily refills.

What Is PageSpeed In cPanel Hosting?

Google PageSpeed is designed to assist you in speeding up your website by automatically applying recommended optimizations to web pages and their assets (CSS, JavaScript, images).

Since is one of the most sought-request we have received so far.

But please note that while we have installed and enabled this on some 6 systems in 3 regions, we are still testing most of mod_pagespeed functions for compatibility, performance, and reliability.

It is important to point out that mod_pagespeed is still in a beta offering, its features might change and thus, we cannot completely guarantee that any enabled modules will not conflict with your website existing content.

We are currently using PageSpeed CoreFilters set of filters which we believe are safe for most websites to make your site go faster.

These are the set of filters that come with the default settings are:

	   add_head
	   combine_css
	   combine_javascript
	   convert_meta_tags
	   extend_cache
	   fallback_rewrite_css_urls
	   flatten_css_imports
	   inline_css
	   inline_import_to_link
	   inline_javascript
	   rewrite_css
	   rewrite_images
	   rewrite_javascript
	   rewrite_style_attributes_with_url

You can see if your website is using Mod_Pagespeed from https://ismodpagespeedworking.com/

But every application, every website, every module, every plugin is unique and different. What works with on website might encounter an issue in the next one. What works in a testing/staging environment may run into issues in production.

The beauty of it all is that while PageSpeed enables itself for the entire server (with global options propagating to all VirtualHosts), it is a behavior that can be overridden per host because it also comes with the ability to limit which host(s) PageSpeed runs on.

If you experience issues with your website or need to see everything as it is by default or notice that the changes you are making on your website are not reflecting in real time), turn Mod_PageSpeed “Off”.

Turning the module on and off

To turn PageSpeed temporarily off, just set this on your .htaccess:

	
		ModPagespeed standby
		OR
		ModPagespeed off
    

To turn it on again, replace the “standby” or “off” with “on

If you want to turn it off completely, and you are a VPS or dedicated customer with system admin access to top-level Apache configuration, use:

	
	   ModPagespeed unplugged
    

If you a VPS or dedicated server customers with “sudo” or “root” access, do note that ModPagespeed on in a virtual host can override a top-level ModPagespeed unplugged directive.

If you need to add anything extra from below, add it one at a time to your testing/dev/staging environment, observe how it affects your website before moving it to production.

You can check out your score at:

We know it could be addictive but don’t think of the 100/100 score on Google PageSpeed Insights solely from a metrics point of view. The whole reason Google developed PageSpeed Insights was as a guideline on best web performance practices to provide recommendations to optimize your site. And by following the guidelines hopefully, you will achieve a faster website.

Gotchas And Things To Watch For

When PageSpeed rewrites a resource, it updates the HTML to refer to the resource by its new name. Generally, PageSpeed leaves the resource at the same origin and path that was originally found in the HTML. However, it is possible to map the domain of rewritten resources. Examples of why this might be desirable include:

mod_pagespeed might rewrite HTML and change references to URLs (e..g style.css) to a cache-extended version. If the browser’s ensuing request for the CSS file winds up on a different server than the HTML file, and that server does not have mod_pagespeed installed, then it won’t be able to decode the resource name to find the CSS file.

This kind of scenarios could be:

– if the server is behind a load balancer, and it’s more efficient to reference the server directly by its IP address, or as ‘localhost’. – the server has a special DNS configuration – the server is behind a firewall preventing outbound connections – the server is running in a CDN or proxy, and must go back to the origin server for the resources – the server needs to service https requests

In these situations, it is possible to map the origin domain of rewritten resources:

	ModPagespeedMapOriginDomain origin_to_fetch_from origin_specified_in_html [host_header]
	ModPagespeedMapRewriteDomain cdn.example2.org *example.org
	ModPagespeedMapOriginDomain localhost *.example.com # Wildcards can also be used in the origin_specified_in_html.
	ModPagespeedMapOriginDomain localhost/example *.example.com # origin_to_fetch_from can include a path after the domain name.

e.g:

	ModPagespeed On 
	ModPagespeedDomain https://www.domain.com 
	ModPagespeedMapOriginDomain https://www-origin.domain.com *.domain.com 
	ModPagespeedMapRewriteDomain www.domain.com www-origin.domain.com 
	ModPagespeedEnableFilters [...] 

Cloudflare & Mod_PagesSpeed

Until we are shown otherwise, we kinda believe that Google’s mod_pagespeed and Cloudflare have no known conflicts at this time.

However, that doesn’t mean that websites with mod_pagespeed enabled cannot experience issues with domains using the CloudFlare.

If it happens, it is because of the fact that both CloudFlare and mod_pagespeed attempts to use compression when serving the website.

This can often be resolved by disabling compression through CloudFlare to avoid redundancy.

Also, if you have added CSS and JS minifications to your .htaccess file, disable the minify JS and CSS options in Cloudflare since you have already enabled them in Pagespeed configuration.

Cloudflare’s CDN and optimization services may be faster because Cloudflare is a CDN (content delivery network) as well, so running mod_pagespeed on a Cloudflare-enabled website may likely be somewhat redundant since many of the features offered by mod_pagespeed are also already available in Cloudflare’s feature set.

WordPress and Mod_PageSpeed

While it is the most popular CMS on the planet, from a developers point of view, WordPress is not the fastest platform out there.

So customers using WordPress often have to use WordPress plugins that deal within minification of JS and CSS files to speed up the application.

Please be careful with these plugins if you are using them on your website along with PageSpeed as they may completely screw up your site and contact forms. We recommend disabling these first and then gradually adding them back if you must use them.

As a general rule, you should definitely avoid using too many plugins and should delete or disable plugins that aren’t being used and use small tweaks using custom coding rather than installing monster plugins which load 2-3 JavaScript or CSS files.

Be careful using both these tools together as it may take time before the conflicts show up. Test, test, and test again before enabling it fully for your WordPress website(s).

Pagespeed can optimize most common image formats, including GIF, PNG, and JPEG, and convert them to PNG, JPEG, or WebP. GIF, PNG, and JPEG are supported by all browsers. WebP is a modern image format that can compress images over 25% more than older formats and is currently supported by many browsers, including Google Chrome, Android 4.0+, and Opera. Note that not all browsers support this: https://caniuse.com/#search=webp. PageSpeed-optimized images are converted to the best format supported by the target browser, i.e., to WebP if it is supported, or PNG or JPEG if not.

Read More

Want regular updates?

Get official news, features and announcements for all cloud products and much more. Thanks for reading — we can’t wait to hear your thoughts.

Subscribe via Newsletter