Appends the current unix timestamp as a query var to your browser's current page in order to break most caches
Popular websites use content distribution networks (CDNs) and other caching strategies to reduce the load on their servers during high-traffic periods. While normally that's fine, sometimes you'd like to quickly bypass that cache, for example, when diagnosing a caching issue, or testing a new feature.
This script works as a bookmarklet, quickly appending the current unix timestamp (an always unique string of numbers) to your browser's current URL, causing the web server to see a URL it's never seen before, and presumably bypassing the cache to serve up a fresh page.
No. This is used for testing caching problems. Besides, it'd be pretty hard to do much damage with a single browser. For example, if you were at https://github.com/benbalter/view-without-cache-bookmarklet
and clicked the bookmarklet, you'd be silently redirected to https://github.com/benbalter/view-without-cache-bookmarklet?dontCache=1427733996267
,
You could just as easily manually add ?asdf
to a URL (followed by ?asdf1
, ?asdf2
, etc.) but you'll quickly start reusing URLs defeating the purpose, or will run into edge cases where the URL already has query vars. The script takes those edge cases into account, and automatically updates its own query var (and preserves other query vars) so you don't have to.
- Visit ben.balter.com/view-without-cache-bookmarklet/
- Drag the link to your bookmark bar
- Click bookmarklet on a page to reload the page sans cache
I'd love your help making the script better. The source lives in src
and the built files live in dist
. To build locally:
- Clone down the repo and
cd
into the directory npm install
- Make your changes
grunt build
Originally, a Gist, migrated March 2015.