pdf.worker.js bypasses JS aggregation - it is loaded directly via URL: $js = "PDFJS.workerSrc = '$worker_loader';";

One of the side effects of this is that the old version of pdf.worker.js will be cached by CDNs, browsers, etc. if/when pdf.js is upgraded.

This typically results in fatal errors in pdf.js

Comments

mfb created an issue. See original summary.

shenzhuxi’s picture

How does your Drupal refresh the cache of the aggregated JavaScript files on CDNs?

mfb’s picture

The way Drupal's aggregated JS works is that there is a new URL when it's regenerated. So, while the old JS may still be cached by the CDN, it's not actually used by the pages because there is a new filename. (Likewise, non-aggregated JS has a URL parameter appended by Drupal core.)

If the JS could be loaded via drupal_add_js() then everything would just work.

mfb’s picture

An alternative would be to append "?v={$library['version']}" onto the URL - this way the JS would be cached under its version number, which would be updated when a new version is installed on the site.

shenzhuxi’s picture

Assigned: Unassigned » shenzhuxi
Category: Bug report » Feature request
Status: Active » Fixed

I put in the 7.x-1.x.

-  $worker_loader = file_create_url(libraries_get_path('pdf.js') . '/build/pdf.worker.js');
+  $worker_loader = file_create_url(libraries_get_path('pdf.js') . '/build/pdf.worker.js') . "?v={$library['version']}";

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.