Compression

Introduction

GZIP HTTP compression is a capability that can be enabled on web servers and web clients to make better use of available bandwidth, and provide greater transmission speeds between both.

HTTP data is compressed before it is sent from the server: compliant browsers will announce what methods are supported to the server before downloading the correct format; browsers that do not support compliant compression method will download uncompressed data.

This feature modifies your .htaccess file. Before the modification a backup file called .htaccess-backup is created. The .htaccess modification adds rules that compress your CSS and JavaScript files.

NoteIf your site is running on NGINX, the CSS and JavaScript compression cannot be controlled by NitroPack, because NGINX does not support dynamic configurations using .htaccess. You will have to contact your hosting provider and ask them to configure compression in NGINX for you.

Use the setting OpenCart Admin Panel > Nitro > Settings > Compression > GZIP Compression Status to Enable / Disable the NitroPack compression.

NitroPack compression saves the compressed content in the following directories:

  • assets/css/ (for CSS files)

  • assets/js/ (for JavaScript files)

  • system/nitro/cache/pagecache/ (for HTML files)

Your PHP user needs to have write permissions to these directories.

NoteSome servers are already configured to compress the served content. If you are using such a server, you will not need to configure NitroPack compression. To check whether compression is enabled on your server, run a PageSpeed Test and check whether it reports uncompressed resources from your domain. Note that it is normal to have some uncompressed resources from third parties like Google, Facebook, Zopim, etc, so only look for resources that are stored on your domain.

CSS compression

compression_css

If you use this feature, it will add .htaccess rules, which modify the HTTP response for all local CSS files by serving a compressed version of these files.

The CSS compression DOES NOT work for the following types of CSS files:

  • CSS files that are served from an external CDN (except the CSS files, served by the Amazon CDN feature of NitroPack)

  • CSS files, which are dynamically created by a PHP script (example: index.php?route=module/css)

  • CSS files, which are served by third-party providers. Such files may appear if you have installed third-party modules on your website

To configure CSS compression go to OpenCart Admin Panel > Nitro > Settings > Compression > CSS files. The following settings are available:

  1. *Compress CSS files (Yes / No) - Turn CSS compression ON / OFF

  2. Compression Level - Set the level of compression for CSS resources. The recommended value is 4, because it is a good balance between compression and speed of compression

  3. Clear compressed CSS files cache - this deletes all NitroPack-generated CSS cache files. They are stored in the folder assets/css/. Your web server needs write permissions to this folder in order to create/delete cache files

JavaScript compression

compression_javascript

If you use this feature, it will add .htaccess rules, which modify the HTTP response for all local JavaScript files by serving a compressed version of these files.

The JavaScript compression does not work for the following types of JavaScript files:

  • JavaScript files that are served from an external CDN (except the JavaScript files, served by the Amazon CDN feature of NitroPack)

  • JavaScript files, which are dynamically created by a PHP script (example: index.php?route=module/js)

  • JavaScript files, which are served by third-party providers. Such files may appear if you have installed third-party modules on your website. An example for such a file is the Google Analytics JavaScript, which is typically served from http://www.google-analytics.com

To configure JavaScript compression go to OpenCart Admin Panel > Nitro > Settings > Compression > JavaScript files. The following settings are available:

  1. Compress JavaScript files (Yes / No) - Turn JavaScript compression ON / OFF

  2. Compression Level - Set the level of compression for JavaScript resources. The recommended value is 4, because it is a good balance between compression and speed of compression

  3. Clear compressed JavaScript files cache - this deletes all NitroPack-generated JavaScript cache files. They are stored in the folder assets/js/. Your web server needs write permissions to this folder in order to create/delete cache files

HTML compression

compression_html

This compresses the content, which is served by NitroPack page cache. Naturally, if you need to use the NitroPack HTML compression, the following requirements must be met:

  1. NitroPack page cache must be enabled. Do this from Cache Systems > Page cache

  2. OpenCart server compression must be disabled. Do this from OpenCart Admin Panel > System > Settings > Edit > Server > Output Compression Level > 0

To configure HTML compression go to OpenCart Admin Panel > Nitro > Settings > Compression > HTML files. The following settings are available:

  1. Compress HTML files (Yes / No) - Turn HTML compression ON / OFF

  2. Compression Level - Set the level of compression for HTML resources. The recommended value is 4, because it is a good balance between compression and speed of compression