-
Notifications
You must be signed in to change notification settings - Fork 0
bust
bust
is a helper to generate a randomized query value to bust a browser's cache.
Don't forget to consult the cookbook to see working snippets solving simple real-world problems.
bust
doesn't provide an elaborate API. Instead it updates io
to include this functionality. Two helper properties and one options
property are defined.
In order to use it, it should be included. No other action is required.
This property allows you to opt-in a cache-busting. If it is truthy, its value is interpreted like that:
-
true
— in this caseio.bustKey
is used to form a cache-busting query value. See below for more details. - a string — the value to use as a query key.
If options.bust
is falsy, an I/O request would not use an automated cache-busting. If options.bust
is truthy, cache module will not cache a request result.
A string, which is used as a cache-busting query key. It can be overridden to customize the default case. Default: "io-bust"
.
You can always supply a cache-busting key value on a per request basis by specifying options.bust
as a desired non-empty string.
I function that actually generates a randomized value to be used with a query key. It takes one parameter: options
object. Default implementation returns a current timestamp (generated by new Date().getTime()
) as a string, and a random value (generated by Math.floor(Math.random() * 1000000)
) as a string, separated by "-"
.
This function is exposed so it can be overridden to customize a cache-busting value.