• Resolved mhair

    (@mhair)


    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?

    • This topic was modified 7 years, 8 months ago by mhair.
Viewing 1 replies (of 1 total)
  • Thank you for getting in touch, but please could you email us on [email protected] for support?

    I would imagine that server-side settings would be far better for setting the cache invalidation times on a WordPress site instead of using the Javascript code, but I’ll be happy to take a closer look if you can email. I may not pick up replies on the forum here.

    Regards,

    Dan

Viewing 1 replies (of 1 total)
  • The topic ‘PDF cache busting in your plugin’ is closed to new replies.