diff --git a/astro.config.mjs b/astro.config.mjs index f047e51..438a2ce 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -41,10 +41,14 @@ export default defineConfig({ { label: "Recipes", items: [ - { label: "Filtering Links", link: "/recipes/filtering-links" }, + { label: "Caching", link: "/recipes/caching" }, { label: "Excluding Paths", link: "/recipes/excluding-paths" }, + { label: "Filtering Links", link: "/recipes/filtering-links" }, + { + label: "Remapping One URL to Another", + link: "/recipes/migration", + }, { label: "Relative Links", link: "/recipes/relative-links" }, - { label: "Migrating Websites", link: "/recipes/migration" }, ], }, { diff --git a/src/content/docs/recipes/caching.md b/src/content/docs/recipes/caching.md new file mode 100644 index 0000000..920697f --- /dev/null +++ b/src/content/docs/recipes/caching.md @@ -0,0 +1,49 @@ +--- +title: Caching +--- + +Caching can significantly speed up repeated checks by reducing requests to the same URL during consecutive runs. For instance, caching responses from `https://github.com` can decrease the load when checking multiple links. Here's how to cache the results of a Lychee run. + +## Caching on the command line + +To cache the results of a lychee run, you can use the `--cache` flag. This +will save the results to a `.lycheecache` file in the current directory. The +next time you run lychee with the `--cache` flag, it will use the cached +results instead of making a new request. + +```bash +lychee --cache --verbose --no-progress './**/*.md' './**/*.html' +``` + +:::tip +Check out the `.lycheecache` file to see the cached results. +It's just a plaintext file with the URLs and their status codes +as well as a UNIX timestamp per entry, which is used to determine +the cache's age. + +The great thing is, that you can remove single lines from the cache +file to re-check the URLs on the next run. It's human-readable and +editable. +::: + + +## Caching in Docker + +If you're running lychee inside a Docker container, caching is still possible, +but a little trickier. + +You need to create a volume to cache the results. This way, the results will persist between runs. + +:::warning +You need to create the `.lycheecache` file in the current directory before +running the Docker container. +::: + +```bash +touch .lycheecache +docker run -it -v $(pwd)/.lycheecache:/.lycheecache lycheeverse/lychee --cache --verbose https://lychee.cli.rs +``` + +## Caching in GitHub Actions + +To see how you can cache the results of a lychee run in GitHub Actions, [check out this page](/github_action_recipes/caching). diff --git a/src/content/docs/recipes/migration.md b/src/content/docs/recipes/migration.md index 86192ae..50d74e4 100644 --- a/src/content/docs/recipes/migration.md +++ b/src/content/docs/recipes/migration.md @@ -1,11 +1,11 @@ --- -title: Migrating Websites +title: Remapping One URL to Another --- Say you move your website from one domain to another. How do you know if you missed to migrate any old links? 🤔 -You can check that with lychee! +You can check that using lychee's `--remap` option! Here's how to check all the links in your sitemap after migrating your website from `example.com` to `example.org`: