Skip to content
This repository has been archived by the owner on Jul 7, 2021. It is now read-only.

A very light weight cache buster module for Magento 1

License

Notifications You must be signed in to change notification settings

justbetter/magento1-cache-buster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Magento 1 Cache Buster

When CSS and/or JS merging in turned on in the backend it's busting cache by adding the last modified date as a query parameter to the merged css and js urls. For example:

<link rel="stylesheet" href="https://yourstore/media/css_secure/3c878a261153f59c071403f9d8fad910.css" />
<script src="https://yourstore/media/js/3c878a261153f59c071403f9d8fad910.js"></script>

Will be:

<link rel="stylesheet" href="https://yourstore/media/css_secure/3c878a261153f59c071403f9d8fad910.css?v=1480691261" />
<script src="https://yourstore/media/js/3c878a261153f59c071403f9d8fad910.js?v=1480691261"></script>

Why should I use this?

Browsers cache css and js files. So when you change such a file it's possible the changes won't take effect. You could clear your browser cache or do a "hard refresh" but all your website visitors should do the same, not really user friendly. By changing the filename after each edit fixes this, so why not change it automatically when a file is changed? That's what this module do!

And no, the the filename hash generated by Magento when js/css merging is enabled does not do this already because it's based on the filenames, hostname and port: md5(implode(',', $files) . "|{$hostname}|{$port}") . '.css';.

Installation

  • Use modman: modman clone https://github.com/justbetter/magento1-cache-buster.git
  • Manually: download, unzip and copy.

Compability

This module overrides just one Magento model but uses the parent function to ensure upgradability. It's tested on Magento 1.9.3.7 but should work on every older version.

Ideas, bugs or suggestions?

Please create a issue or a pull request.

License

MIT

About us

We’re a innovative development agency from The Netherlands building awesome websites, webshops and web applications with Laravel and Magento. Check out our website justbetter.nl and our open source projects.


JustBetter logo