Web / Caddy Server Interview questions
What is the encode directive used for?
encode compresses HTTP response bodies before sending them to the client, reducing transfer size for text-based content like HTML, CSS, JavaScript, and JSON.
example.com { encode zstd gzip file_server }
Caddy negotiates the format based on the client's Accept-Encoding header and picks the best match from the algorithms listed, preferring zstd over gzip when both are offered here. It skips compression for already-compressed types (like images) and for responses below a minimum size, since compressing tiny payloads wastes CPU for no real benefit.
More Related questions...