matrix-org / matrix-org/matrix-viewer
Occasionally assets fail to load (404)
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 84
- Forks
- 10
- PR merge metrics
- No merged PRs in 30d
Description
Occasionally our assets fail to load and a return a 404 (observed on https://archive.matrix.org/). It seems like this spawns from our origin server serving a `404` : `Cannot GET /assets/styles-63d89b7d.css` (Express error). So for some reason the `express.static(...)` call can't find our assets on disk.
https://github.com/matrix-org/matrix-public-archive/blob/5caf9dc1b8d5e98fdc99ab06ab9b9d09d2f546ed/server/routes/install-routes.js#L42-L43
Cloudflare will [cache our 404 responses for 3 minutes](https://developers.cloudflare.com/cache/how-to/configure-cache-status-code/). And things seem to come back after the cache expires.
This is a bit confusing though because Cloudflare should be caching our assets forever (for 1-year) after seeing a successful response. I even see the `Cache-Control: max-age=31536000` header in place and responds with `Cf-Cache-Status: HIT` indicating that Cloudflare is using the cache.
### Potential solutions
#### Find the root cause
What's causing Express to not be able to find the assets on disk sometimes?
#### Always serve the `/assets` from Nginx
We could maybe workaround the problem by serving the `/assets` directory directly from nginx instead of relying on Express. I'd rather find the root cause first in any case.
#### Why isn't Cloudflare serving the cached response?
*To be determined*
Or what's causing Cloudflare to bust it's own cache when our origin server starts spitting out a 404?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with server/routes/install-routes.js at lines 42–43 and inspect how express.static serves the assets. Reproduce or trace the intermittent origin 404s alongside the Cloudflare cache behavior; done means identifying the root cause and validating either a fix or the proposed Nginx workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- express, javascript, nginx
- Domain
- backend, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100