pdf documents will have a cache busting
This file contains 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
<script type="text/javascript"> | |
jQuery(document).ready(function($){ | |
// All pdf documents will have a cache busting | |
// string added to its url | |
$("a[href $='.pdf']").click(function(){ | |
var now = new Date().getTime(); | |
$(this).attr('href', $(this).attr('href') + '?cache=' + now ); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had a need to cache a pdf file and came up with this idea.
It takes the link to the pdf file and adds a random number to the query that will stop the browser from caching the file, in this case a pdf.
It can easily be modified for any link type