Created
September 4, 2017 01:34
-
-
Save hibuno/23056e6826f5ad3ba1928c8a498dd2b9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createHash() { | |
var text = ""; | |
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | |
for (var i = 0; i < 32; i++) | |
text += possible.charAt(Math.ceil(Math.random() * possible.length)); | |
return text; | |
} | |
function preventCaching() { | |
var script = $('script[type="text/javascript"]'), | |
style = $('link[rel="stylesheet"]'); | |
style.map(function(k,v) { | |
$(v).attr('href', $(v).attr('href') + '?' + createHash()); | |
}); | |
script.map(function(k,v) { | |
$(v).attr('src', $(v).attr('src') + '?' + createHash()); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment