@@ -26,9 +26,8 @@ import { IUpdateDiscord, updateDiscord } from "../functions/discord.js";
2626import rateLimiter from "api/plugins/rateLimiter.js" ;
2727
2828const repeatOptions = [ "weekly" , "biweekly" ] as const ;
29- const EVENT_CACHE_SECONDS = 90 ;
3029const CLIENT_HTTP_CACHE_POLICY =
31- "public, max-age=180 , stale-while-revalidate=420, stale-if-error=3600" ;
30+ "public, max-age=120 , stale-while-revalidate=420, stale-if-error=3600" ;
3231export type EventRepeatOptions = ( typeof repeatOptions ) [ number ] ;
3332
3433const baseSchema = z . object ( {
@@ -121,21 +120,6 @@ const eventsPlugin: FastifyPluginAsync = async (fastify, _options) => {
121120 const upcomingOnly = request . query ?. upcomingOnly || false ;
122121 const host = request . query ?. host ;
123122 const ts = request . query ?. ts ; // we only use this to disable cache control
124- const cachedResponse = fastify . nodeCache . get (
125- `events-upcoming_only=${ upcomingOnly } ` ,
126- ) as EventsGetResponse ;
127- if ( cachedResponse ) {
128- if ( ! ts ) {
129- reply . header ( "Cache-Control" , CLIENT_HTTP_CACHE_POLICY ) ;
130- }
131- let filteredResponse = cachedResponse ;
132- if ( host ) {
133- filteredResponse = cachedResponse . filter ( ( x ) => x [ "host" ] == host ) ;
134- }
135- return reply
136- . header ( "x-acm-cache-status" , "hit" )
137- . send ( filteredResponse ) ;
138- }
139123 try {
140124 let command ;
141125 if ( host ) {
@@ -188,13 +172,6 @@ const eventsPlugin: FastifyPluginAsync = async (fastify, _options) => {
188172 }
189173 } ) ;
190174 }
191- if ( ! host ) {
192- fastify . nodeCache . set (
193- `events-upcoming_only=${ upcomingOnly } ` ,
194- parsedItems ,
195- EVENT_CACHE_SECONDS ,
196- ) ;
197- }
198175 if ( ! ts ) {
199176 reply . header ( "Cache-Control" , CLIENT_HTTP_CACHE_POLICY ) ;
200177 }
@@ -301,9 +278,6 @@ const eventsPlugin: FastifyPluginAsync = async (fastify, _options) => {
301278 }
302279 throw new DiscordEventError ( { } ) ;
303280 }
304- fastify . nodeCache . del ( "events-upcoming_only=true" ) ;
305- fastify . nodeCache . del ( "events-upcoming_only=false" ) ;
306- fastify . nodeCache . del ( `event-${ entryUUID } ` ) ;
307281 reply . status ( 201 ) . send ( {
308282 id : entryUUID ,
309283 resource : `/api/v1/events/${ entryUUID } ` ,
@@ -354,9 +328,6 @@ const eventsPlugin: FastifyPluginAsync = async (fastify, _options) => {
354328 id,
355329 resource : `/api/v1/events/${ id } ` ,
356330 } ) ;
357- fastify . nodeCache . del ( "events-upcoming_only=true" ) ;
358- fastify . nodeCache . del ( "events-upcoming_only=false" ) ;
359- fastify . nodeCache . del ( `event-${ id } ` ) ;
360331 } catch ( e : unknown ) {
361332 if ( e instanceof Error ) {
362333 request . log . error ( "Failed to delete from DynamoDB: " + e . toString ( ) ) ;
@@ -387,14 +358,6 @@ const eventsPlugin: FastifyPluginAsync = async (fastify, _options) => {
387358 async ( request : FastifyRequest < EventGetRequest > , reply ) => {
388359 const id = request . params . id ;
389360 const ts = request . query ?. ts ;
390- const cachedResponse = fastify . nodeCache . get ( `event-${ id } ` ) ;
391- if ( cachedResponse ) {
392- if ( ! ts ) {
393- reply . header ( "Cache-Control" , CLIENT_HTTP_CACHE_POLICY ) ;
394- }
395- return reply . header ( "x-acm-cache-status" , "hit" ) . send ( cachedResponse ) ;
396- }
397-
398361 try {
399362 const response = await fastify . dynamoClient . send (
400363 new GetItemCommand ( {
@@ -406,7 +369,6 @@ const eventsPlugin: FastifyPluginAsync = async (fastify, _options) => {
406369 if ( ! item ) {
407370 throw new NotFoundError ( { endpointName : request . url } ) ;
408371 }
409- fastify . nodeCache . set ( `event-${ id } ` , item , EVENT_CACHE_SECONDS ) ;
410372
411373 if ( ! ts ) {
412374 reply . header ( "Cache-Control" , CLIENT_HTTP_CACHE_POLICY ) ;
0 commit comments