The Intent of ?ver=1.0.0
Lab: Remove Query String from Static Resource URL
Video Runtime: 12:22
Why does WordPress append the
?ver= whatever your version number is? Why does it ask us to provide a version number when we enqueue? Why?
What is the intent of versioning?
Answer: It’s for cache busting.
In order for the latest version of an asset/resource file to be seen in someone’s browser when they return to the website, we have to change the static URL of that asset/resource.
Why? Browsers cache when you view the web page. It holds a local version in its cache. If the URL doesn’t change, then the browser will pull from its local cache. That means the viewer will NOT see your changes.Pro Tip: Assign version numbers when enqueuing assets in #WordPress to bust through the cache. Click To Tweet
Whoopsie. Appending the version number of the asset to its static URL changes the URL.
That’s why WordPress handles it for you. But you are responsible to add that version number when enqueuing.
There’s a time to code and …. yup, that sums it up.
Total Lab Runtime: 03:18:22
- 1 Lab Introductionfree 09:30
- 2 What is a URL Query String?free 14:36
- 3 The Intent of ?ver=1.0.0free 12:22
- 4 Understanding the Problemfree 14:01
- 5 Cache Busting Strategiesfree 09:57
- 6 Planning Our Pluginpro 18:17
- 7 Versioning Utility Helper Filepro 08:36
- 8 Start the URL Converter Classpro 18:11
- 9 Hook into WordPresspro 11:57
- 10 Regex or Parse the URL?pro 12:30
- 11 Convert with Regexpro 06:10
- 12 Apache and Nginx Rewrite Rulespro 10:43
- 13 Deciding Whether to Convertpro 07:35
- 14 Skip When No Version Query Stringpro 09:18
- 15 Only the Local Assetspro 14:09
- 16 Improving Our Code & Readabilitypro 11:52
- 17 Test, Fine-Tune, and Wrap it Uppro 08:38