The Odyssey Timeship - the golden timeship against deep space, from the original 2001 site banner

Content type cache

How lazysite caches content types for raw and api mode pages.

Content type cache

Pages with non-default content types (raw mode, api mode, or custom content_type:) store the content type in a sidecar cache file so that cache hits can serve the correct Content-type header without re-reading the source.

Storage location

public_html/lazysite/cache/ct/

Filename format

Path separators are replaced with colons. For example, api/status becomes api:status.ct. The file contains only the content type string.

When written

A .ct file is written when the page's content type is not the default text/html; charset=utf-8. This applies to:

When read

On cache hits (the fast path in main()), the .ct file is read to determine the correct Content-type header. If no .ct file exists, the default text/html; charset=utf-8 is used.

Cleanup

When a page is rendered and its content type is the default (or undefined), any existing .ct file for that path is deleted. This handles the case where a page changes from api: true back to normal mode.

Example

$ cat public_html/lazysite/cache/ct/api:status.ct
application/json; charset=utf-8

Notes