Serving the file
On the fly
Section titled “On the fly”With the route imported, GET /llms.txt builds the file on each request, with a public Cache-Control of max_age
seconds. The file is rendered whole before the response starts, into a php://temp buffer that spills to a temporary
file past 256 KiB, so the memory stays flat and:
- a listener failing half way gives an error page, never a truncated
200left in the caches - the response carries a
Content-Lengthand anETag, and answers304 Not Modifiedto a matchingIf-None-Match
Dumped
Section titled “Dumped”php bin/console llms-txt:dumpphp bin/console llms-txt:dump --base-url=https://example.com # without "framework.router.default_uri"php bin/console llms-txt:dump var/llms_txt # another directoryThe file is streamed to a temporary file next to it, renamed once complete: the web server never serves a half written file, and a failing listener leaves the previous one in place.
- Into
public/(the default): the web server serves it without booting Symfony. The route is a fallback until the first dump: remember to dump again, from a cron or after a deployment, or the file goes stale. - Elsewhere (
dump_directory: '%kernel.project_dir%/var/llms_txt'): the controller serves the dumped file when there is one, withETagandLast-Modified, and builds it on the fly otherwise.
