• Resolved p15h

    (@prestonwordsworth)


    Dear Goossens

    Many thanks for this extremely helpful plugin.

    Just wondered if it’s possible to have the ability to generate all the static autoptimize_hash.css/js files manually in bulk, and not wait until a page gets actually hit.

    We recently implemented a service worker using GoogleChromeLabs’ pwa-wp plugin, and turns out it could only precache an asset when first activated on a page if the assets for the pages to be precached already exist in some directory:

    workbox.routing.registerRoute(/wp-content\/cache\/autoptimize\/.+/, workbox.strategies.cacheFirst());

    So it seems like a capability to manually generate css/js cache is needed for a service worker to work with Autoptimize.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    no, afraid AO creates file right after the HTML gets created by WordPress at which point it extracts the CSS/ JS to optimize. without a page being requested no optimized assets can be created.

    hope this clarifies,
    frank

    Thread Starter p15h

    (@prestonwordsworth)

    That makes sense, Frank. I appreciate the prompt response.

    So what we did is we automated requests for htmls to happen whenever AO cache gets cleared, to speed up cache building. We also set the precaching route to /path/to/autoptimize_[a-z0-9]+.css etc to avoid service worker caching the autoptimize_snippet_hash.css/js files residing in the same folders.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    So what we did is we automated requests for htmls to happen whenever AO cache gets cleared, to speed up cache building.

    that indeed looks like the correct approach ??

    We also set the precaching route to /path/to/autoptimize_[a-z0-9]+.css etc to avoid service worker caching the autoptimize_snippet_hash.css/js files residing in the same folders.

    this might not apply, but in certain configurations you might also have autoptimioze_single_hash.css/js files, in which case you might have to tweak your solution a bit?

    Thread Starter p15h

    (@prestonwordsworth)

    Yes we do! So /path/to/autoptimize_(?:single_)?[a-z0-9]+.(?:css|js)

    Thank you very much for reminding us!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Manually generate cache for service worker’ is closed to new replies.