Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache busting plugin #352

Open
oscarotero opened this issue Jan 6, 2023 · 9 comments
Open

Cache busting plugin #352

oscarotero opened this issue Jan 6, 2023 · 9 comments
Labels
enhancement New feature or request Idea plugins

Comments

@oscarotero
Copy link
Member

Enter your suggestions in details:

Related: #350

A plugin to search links to images, css, videos, etc in the html pages and add a suffix. Then, it adds the same suffix to the files.

@oscarotero oscarotero added enhancement New feature or request Idea plugins labels Jan 6, 2023
@ajschmidt8
Copy link

just checking in. any updates on this feature?

@oscarotero
Copy link
Member Author

@ajschmidt8 No yet. I'll create a first version in the expiremental plugins repo, for testing.

@RickCogley
Copy link

Hopefully it could work with any sort of downloadables. We have clients who ask us to link a PDF of theirs on their site, and we do it, then soon after they send another with some small typo fixed. We always manually add a date tag and serial letter like 20231230A, but automation sounds sweet!

@andy-preston
Copy link

andy-preston commented Jun 18, 2024

Workaround.

Have a _data.ts file with:

export const cacheBuster = `${new Date().getTime()}`;

Then, in your template, you can do something like.

<link rel="stylesheet" href="/style.css?cb={{ cacheBuster }}">

It doesn't solve every use-case but it's just right for styles and suchlike.

@RickCogley
Copy link

RickCogley commented Jun 24, 2024

Thanks, this is just right and I confirm it works!

It doesn't solve every use-case but it's just right for styles and suchlike.

@oscarotero
Copy link
Member Author

The cache_busting experimental plugin has been upgraded to Lume 2

@RickCogley
Copy link

@oscarotero thank you very much for putting the time in to upgrade this. I tried it right away but without success. The error I'm getting is:

❯ deno task lume upgrade
Task lume export TZ='Asia/Tokyo' && echo "import 'lume/cli.ts'" | deno run -A - "upgrade"
Update successful!
Your Lume version is: v2.2.2
❯ deno task lume --serve
Task lume echo "import 'lume/cli.ts'" | deno run -A - "--serve"
Loading config file file:///Users/rcogley/dev/help.esolia.pro/_config.ts
TypeError: Failed to execute 'digest' on 'SubtleCrypto': Argument 2 is not an ArrayBuffer or a view on one
    at makeException (ext:deno_webidl/00_webidl.js:91:10)
    at Array.converters.BufferSource (ext:deno_webidl/00_webidl.js:644:11)
    at SubtleCrypto.digest (ext:deno_crypto/00_crypto.js:518:30)
    at getContentHash (https://raw.githubusercontent.com/lumeland/experimental-plugins/c8778bfbf480f57a2357ab94bc22290b8bf11d12/cache_busting/mod.ts:110:46)
    at getHash (https://raw.githubusercontent.com/lumeland/experimental-plugins/c8778bfbf480f57a2357ab94bc22290b8bf11d12/cache_busting/mod.ts:70:33)
    at eventLoopTick (ext:core/01_core.js:168:7)
    at async addHash (https://raw.githubusercontent.com/lumeland/experimental-plugins/c8778bfbf480f57a2357ab94bc22290b8bf11d12/cache_busting/mod.ts:60:20)
    at async Object.replace [as fn] (https://raw.githubusercontent.com/lumeland/experimental-plugins/c8778bfbf480f57a2357ab94bc22290b8bf11d12/cache_busting/mod.ts:41:16)
    at async https://deno.land/x/lume@v2.2.2/plugins/modify_urls.ts:65:15
user=2.68s system=1.80s cpu=57% total=7.823

How I'm loading:

import cache_busting from "https://raw.githubusercontent.com/lumeland/experimental-plugins/c8778bfbf480f57a2357ab94bc22290b8bf11d12/cache_busting/mod.ts";
...
.use(cache_busting())
...

My deno.json:

{
  "importMap": "./import_map.json",
  "tasks": {
    "lume": "echo \"import 'lume/cli.ts'\" | deno run -A -",
    "build": "deno task lume",
    "serve": "deno task lume -s",
    "update-deps": "deno run -A 'https://deno.land/x/nudd@v0.2.5/cli.ts' update deno.json"
  },
  "compilerOptions": {
    "types": [
      "lume/types.ts"
    ]
  }
}

I tried adding "import" specifying lume 2.2.2 but it made no difference.

I did deno task update-deps and deno task lume upgrade in the project, and both appear to have completed successfully. The above error was after both of these commands had been executed.

@oscarotero
Copy link
Member Author

It works fine to me. Are you using the latest version of Deno?

Anyway, I've detected some issues in this plugin if it's combined with other plugins like inline or transformImages. So if it doesn't work fine for you, maybe #352 (comment) is a better solution

@RickCogley
Copy link

Hello - I upgraded Deno but it doesn't change. One repo I tried it on is definitely using transformImages. The other is using the wiki template which I may have added ogImages and favicon plugins to, so, maybe those have an impact. At any rate the other method works for what I need. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Idea plugins
4 participants