“Use your browser cache” for the Google Analytics module in Prestashop

If you are struggling with the optimization problem of Prestashop for Google PageSpeed Insights for the Google Analytics module (JavaScript) loaded from Google servers, I have a solution for you – the Prestashop Module!

The problem is that the ganalytics module loads the content of scripts directly from Google servers that we can not keep in the cache. In this case, we must set the HTTP headers for these files (Expires), which should be on our server and be kept for some time in the client’s browser cache. The best way to add the Expires headers is to add the following code to the .htaccess file in the main directory of your Prestashop:

Adding the above Expires headers will improve the PageSpeed Insights result in the test but it still does not solve the problem. To fully support the Google Analytics file from my own server, install my module which you can download below:

 

How it works?

The module clipartoptimizegoogleanalytics (Optymize Google Analytics) overwrites the functions of the original ganalytics module (Google Analytics for Prestashop) in such a way that the script does not download the content of JavaScript files from external sources. The module has a tool that should be set in the task schedule (cron) so that JavaScipt files are downloaded and updated on the server.

Installation guide

STEP1: Install the module with the standard tool for adding Prestashop modules: Modules and services -> Add a new module and then “Install”

STEP 2: Go to the module configuration and copy the generated URL to the CRON tool which should be called cyclically once a day. The url should be pasted into the hosting panel in the Task Scheduler (Cron) tool. Below is an example for the Ajenti panel:

 

CLIP-ART Radosław Balcerzak - we have been operating on the market for over 10 years. We specialize in the comprehensive implementation of websites and online stores.

  • ul. Słoneczna 11B, 64-730 Rosko
  • +48 609 880 234
  • office@balcerzak.it

Newsletter

Subscribe to the newsletter to receive information about new products!