Q29: How do `req.fresh` and `req.stale` support HTTP Caching?
req.fresh: Returnstrueif client conditional cache headers (If-None-Match,If-Modified-Since) match current response headers, indicating the client's cache is fresh.req.stale: Inverse ofreq.fresh. Returnstrueif client cached data is stale, indicating updated data must be transmitted.
Key Takeaways
- If
req.freshistrue, respond withres.status(304).end()to save network bandwidth. - Helps automate HTTP/1.1 cache validation responses.