From 002af474f8317f15623e714fd5fbf542d59c6ede Mon Sep 17 00:00:00 2001 From: Matchu Date: Tue, 16 Nov 2021 12:04:16 -0800 Subject: [PATCH] Don't HTTP cache currentUserOwnsThis/wants Hmm, I see, Vercel chews on Cache-Control headers a bit more than I'm used to, so anything marked `scope: PRIVATE` would not be cached at all. But on a more standard server, this was coming out as privately cacheable, but for an actual amount of time (1 hour in the homepage case), because of the `maxAge` on other fields. That meant the device browser cache would hold onto the result, and not always reflect Own/Want changes upon page reload. In this change, we set `maxAge: 0`, because we want this field to be very responsive. I also left `scope: PRIVATE`, even though I think it doesn't really matter if we're saying the field isn't cacheable anyway, because I want to set the precendent that `currentUser` fields need it, to avoid a potential gotcha if someone creates a cacheable `currentUser` field in the future. (That's important to be careful with though, because is it even okay for logouts to not clear it? TODO: Can we clear the private HTTP cache somehow? I guess we would need to include the current user ID in the URL?) --- src/server/types/Item.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/types/Item.js b/src/server/types/Item.js index ef6c700..129aea4 100644 --- a/src/server/types/Item.js +++ b/src/server/types/Item.js @@ -33,8 +33,8 @@ const typeDefs = gql` """ wakaValueText: String @cacheControl(maxAge: ${oneHour}) - currentUserOwnsThis: Boolean! @cacheControl(scope: PRIVATE) - currentUserWantsThis: Boolean! @cacheControl(scope: PRIVATE) + currentUserOwnsThis: Boolean! @cacheControl(maxAge: 0, scope: PRIVATE) + currentUserWantsThis: Boolean! @cacheControl(maxAge: 0, scope: PRIVATE) """ How many users are offering/seeking this in their public trade lists.