TiddlyWiki5/editions/tw5.com/tiddlers/webserver/Using the integrated static...

32 lines
2.1 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

created: 20180703095630828
modified: 20240413045124764
tags: [[WebServer Guides]]
title: Using the integrated static file server
type: text/vnd.tiddlywiki
Any files in the subfolder `files` of the wiki folder will be available via the route `\files\<uri-encoded-filename>`. For example: http://127.0.0.1:8080/files/Motovun%20Jack.jpg
This can be useful for publishing large files that you don't want to incorporate into the main wiki (PDFs, videos, large images, etc.).
Static files can be referenced directly:
* `[ext[./files/a-big-document.pdf]]` - to make a link to a PDF
* `[img[./files/a-big-image.png]]` - to embed an image
Alternatively, the ''_canonical_uri'' field can be used to reference the files as [[external tiddlers|ExternalImages]].
If [[WebServer Parameter: use-browser-cache]] is used, these files will be cached by the client's browser to save on bandwidth. In this case, the `cache busting strategy` can be used to make sure the client always has the latest updated files.
<<<
https://javascript.plainenglish.io/what-is-cache-busting-55366b3ac022
!! Cache Busting
There are a couple different ways of changing the names of files so that they will load when they change. One way is to use version numbers and have them somewhere in the file name when loading. You could have a subdirectory for every version, `v1/index.js` `v2/index.css` . You could also have the version in queries in the URLs, `index.js?v1` , `index.css?v2` .
Another way is to change the name of the file, `index.v1.js` , `index.v2.css` . These ways are not as manageable because this can become very hard once you have a ton of files that are being changed.
A more popular and manageable way is to keep hashes inside the file names. Hashes, if you dont know, are fixed length character representations of any content and they are irreversible, meaning you can get the hash from the file but you cant get the file from the hash. Hashes are perfect for this, because when a file changes its hash will change, so if we keep the hash inside the filename `index.[someHashHere].js` browsers will detect it and load it instead of an old file.
<<<