#1779·planka

[Bug]: Cache-Control max-age on streamed files is in milliseconds

Author: uppertoeCreated Sep 16, 2026Updated Sep 16, 2026

Where is the problem occurring?

Server

What browsers are you seeing the problem on?

Firefox

Current behavior

serveStatic in server/config/routes.js sets

javascript
'Cache-Control': `private, max-age=${sails.config.http.cache}, immutable`,

sails.config.http.cache is in milliseconds (it is Sails' input to serve-static's maxAge), so browsers receive max-age=31557600000. The directive takes seconds.

Firefox parses max-age into a 32-bit unsigned integer with an overflow check (CacheControlParser::SecondsValue) and treats a larger value as invalid. It drops the directive and falls back to heuristic freshness, so project background images, avatars and favicons re-download far more often than intended and immutable has no effect. Chrome parses the value as 64-bit and is unaffected, which is probably why this has not been noticed.

Desired behavior

max-age in seconds, so every browser keeps these files for the intended year:

javascript
'Cache-Control': `private, max-age=${Math.floor(sails.config.http.cache / 1000)}, immutable`,

Steps to reproduce

  1. Log in on Firefox and open a project with an image background.
  2. In the Network panel, inspect the response for /background-images/<id>/original.<ext>. It carries cache-control: private, max-age=31557600000, immutable.
  3. Load the board again a few minutes later. The image is fetched again rather than served from cache.

Other information

Seen on 2.1.0. The line is unchanged on master as of de4d768.