nkprasad12 / morcus-net

Source code for Morcus Latin Tools.
https://morcus.net
GNU General Public License v3.0
6 stars 3 forks source link

API requests are not cached #264

Open nkprasad12 opened 10 months ago

nkprasad12 commented 10 months ago

Currently, there's no caching set for these. One simple heuristic would be to allow caching for GET requests for a small amount of time, e.g.

if (route.method === "GET") {
  res.setHeader("Cache-Control", "public, max-age=30");
 }

which would work well for use cases like someone hitting the back button. Another possibility would be changing GET API requests to include the commit hash of the client bundle and setting the cache to some very long time (e.g. a year), so that any e.g. article is cached for that bundle.