Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
pdf documents will have a cache busting
<script type="text/javascript">
// 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 );
Copy link

hillbilly commented Jan 19, 2014

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment