Knowledge base Bug Active
downloadBytes ignores headers set with setHeader
In shortA response sent with docly.downloadBytes does not include headers set earlier with docly.setHeader - Cache-Control, Last-Modified and similar are missing. The same headers do appear on an ordinary JSON response from the same script. Files served this way are therefore not cached by the browser.
Applies to API scriptsFilesCaching
-
What you'll see
You serve images or files from an API script - for example thumbnails behind access control - and set
Cache-Controlso the browser keeps them. Every page view downloads and scales them again. -
What's actually happening
Measured 2026-11-28:
docly.setHeader("Cache-Control", "private, max-age=86400")followed byreturn docly.downloadBytes(...)returned the file without the header. The samesetHeadercall followed by an ordinary object return produced the header on the JSON response. -
What to do
Until this is resolved, do not rely on browser caching for files served with
downloadBytes:- Put a version in the URL (for example
?v=<LastModified ticks>), so that a changed file always gets a new address. - Keep such endpoints for files that are small or rarely viewed. For many or large files, store a ready-made derivative instead of producing it on every request.
- Put a version in the URL (for example
Last reviewed 28 Nov 2026