Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Running Google's PageSpeed Insights shows that Google does not set proper browser caching headers on it's js file. Setting the file to load locally actually reduces the score because there is no gzipped version of the file. This is a request to implement code to gzip the local js file when it's retrieved from google.
Comment | File | Size | Author |
---|---|---|---|
#5 | gzip_locally_cached_file--2571481-5.patch | 4.52 KB | Dom. |
| |||
#2 | 2571481-1.patch | 1.95 KB | slydevil |
Comments
Comment #2
slydevil CreditAttribution: slydevil commentedPatch attached
Comment #3
hass CreditAttribution: hass commentedComment #4
hass CreditAttribution: hass commentedComment #5
Dom. CreditAttribution: Dom. as a volunteer and at ACINO commentedHere is a port of patch #2 to current dev.
This patch also provides a "Enable Gzip compression" option (just below 'locally cache tracking code' option: it appears only if this option is checked).
To test the patch:
- test your site with page speed : make sure the warning about analytics.js not being gzipped is visible
- patch the module
- navigate to /admin/config/system/google-analytics: enable cache and gzip options
- clear the analytics.js file in files/google_analytics/analytics.js
- run cron
- navigate to a page of your site anonymously
- check that analytics.js.gz is created
- test your site with page speed : make sure the warning about analytics.js not being gzipped has disappeared
Comment #6
lathanmy site is deployed on pantheon i can not remove the file in files/google_analytics/analytics.js
should this patch not do that in an update hook?
Comment #7
Dom. CreditAttribution: Dom. as a volunteer and at ACINO commentedThan you will have to wait for next file regeneration. It is rebuilt on cron, every upon a while depending on your configuration.
Comment #9
hass CreditAttribution: hass commentedI think this is too complicated. If we know core does gzip'ing of JS we can also do it the same way. I think there is no additional setting required at all.
Comment #10
hass CreditAttribution: hass commentedI guess everything we need to do is saving a .gz file in the same folder
core
.htaccess
will manage the rest:Comment #11
hass CreditAttribution: hass commented