Currently, Isomer uses a huge amount of tokens due to not caching. This leads to scaling issue, where our github token limits are quickly reached and users are unable to access the CMS.
use an external package axios-cache-interceptor to utilise ETags for cache. See here for info on etags.
note that this is using in memory storage. the implications are that: we could potentially have some requests that could be cached but are not (current ETag value is 1 -> user A edits -> ETag value now 2 -> other instance doesn't knows -> queries from other instance -> ETag value updated)
potential for stale reads - github will tell us if the old etag value is outdated or not (ie, return 200) but the package uses the cache-control header to control freshness (which is good). because github's header sets max-age=60, the package will internally use the old value for 60s.
Tests
first, add a console.log for remainingRequests into respHandler for AxiosInstance.ts, so that we know how much requests are remaining
next, issue a GET request to the e2e-test-repo's homepage (curl --request GET \ --url http://localhost:8081/v2/sites/e2e-test-repo/homepage)
observe the # of requests remaining.
repeat steps 2-3; the # of requests remaining should be unchanged
this is because of 2 reasons - ETag functionality only added in 0.6 + their import for object-code is an outdated one, which doesn't get fixed till 0.9.2.
Problem
Currently, Isomer uses a huge amount of tokens due to not caching. This leads to scaling issue, where our github token limits are quickly reached and users are unable to access the CMS.
Closes IS-172
Solution
axios-cache-interceptor
to utilise ETags for cache. See here for info on etags.cache-control
header to control freshness (which is good). because github's header setsmax-age=60
, the package will internally use the old value for 60s.Tests
console.log
forremainingRequests
intorespHandler
forAxiosInstance.ts
, so that we know how much requests are remainingGET
request to thee2e-test-repo
's homepage (curl --request GET \ --url http://localhost:8081/v2/sites/e2e-test-repo/homepage
)New dependencies:
axios-cache-interceptor
: interceptor for axios to use etags. the current backing storage is in memory.Deploy notes
axios
got upgraded from0.21.x
to0.25.0
0.9.2
as a minimum foraxios-cache-interceptor
ETag
functionality only added in0.6
+ their import forobject-code
is an outdated one, which doesn't get fixed till0.9.2
.