PDF cache busting in your plugin
-
In our previous flat-file html site, I used this code to bust the cache and show any updated pdf file in a fast-moving workgroup type site that updates pdfs often. It works quite well.
jQuery(document).ready(function($){
// All pdf documents will have a cache busting
// string added to its url to guarantee freshness of updated documents$(“a[href $=’.pdf’]”).click(function(){
var now = new Date().getTime();
$(this).attr(‘href’, $(this).attr(‘href’) + ‘?cache=’ + now );
});});
However, because this pdf is embedded by javascript in the page dynamically and not viewed as a URL, this obviously doesn’t work. Is there an equivalent way to bust the cache with your plugin for frequently updated pdfs, using a hash or parameterized timestamp of some sort?
- The topic ‘PDF cache busting in your plugin’ is closed to new replies.