From 595d76e47468d36632da32747c1850cc0f3f9d57 Mon Sep 17 00:00:00 2001 From: Daniel Saewitz Date: Tue, 19 Sep 2023 16:34:56 -0400 Subject: [PATCH] Disable caching on most fetch requests --- .../[artistSlug]/[year]/[month]/[day]/layout.tsx | 2 +- src/app/(main)/(secondary)/today/page.tsx | 2 +- src/app/queries.tsx | 2 +- src/components/ShowsColumn.tsx | 2 +- src/components/YearsColumn.tsx | 2 +- src/redux/modules/shows.js | 13 ------------- 6 files changed, 5 insertions(+), 18 deletions(-) diff --git a/src/app/(main)/(home)/[artistSlug]/[year]/[month]/[day]/layout.tsx b/src/app/(main)/(home)/[artistSlug]/[year]/[month]/[day]/layout.tsx index e433d2e..ea6e092 100644 --- a/src/app/(main)/(home)/[artistSlug]/[year]/[month]/[day]/layout.tsx +++ b/src/app/(main)/(home)/[artistSlug]/[year]/[month]/[day]/layout.tsx @@ -17,7 +17,7 @@ export const fetchShow = async ( if (!slug || !year || !displayDate) return { sources: [] }; const parsed = (await ky(`${API_DOMAIN}/api/v2/artists/${slug}/years/${year}/${displayDate}`, { - next: { revalidate: 60 * 5 }, + cache: 'no-cache', }).json()) as Tape; return parsed; diff --git a/src/app/(main)/(secondary)/today/page.tsx b/src/app/(main)/(secondary)/today/page.tsx index 17e6dcf..73b48b9 100644 --- a/src/app/(main)/(secondary)/today/page.tsx +++ b/src/app/(main)/(secondary)/today/page.tsx @@ -5,7 +5,7 @@ import { Artist, Day } from '../../../../types'; export default async function Page() { const data: Day[] = await fetch(`${API_DOMAIN}/api/v2/shows/today`, { - next: { revalidate: 60 * 5 }, // seconds + cache: 'no-cache', // seconds }).then((res) => res.json()); const artists: Artist[] = data.map((day: Day) => ({ diff --git a/src/app/queries.tsx b/src/app/queries.tsx index d06a1aa..3ecdee6 100644 --- a/src/app/queries.tsx +++ b/src/app/queries.tsx @@ -4,7 +4,7 @@ import { Artist } from '@/types'; export const fetchArtists = async (): Promise => { const parsed = await ky(`${API_DOMAIN}/api/v2/artists`, { - next: { revalidate: 60 * 5 }, + next: { revalidate: 60 * 5 }, // leaving for now, should revisit cache (I dont think this works) }) .json() .catch((err) => { diff --git a/src/components/ShowsColumn.tsx b/src/components/ShowsColumn.tsx index b60bd2a..6a8ce95 100644 --- a/src/components/ShowsColumn.tsx +++ b/src/components/ShowsColumn.tsx @@ -16,7 +16,7 @@ const fetchShows = async (slug?: string, year?: string): Promise => { if (!slug) return []; const parsed = await ky(`${API_DOMAIN}/api/v2/artists/${slug}/years`, { - next: { revalidate: 60 * 5 }, + cache: 'no-cache', }) .json() .catch(() => { diff --git a/src/redux/modules/shows.js b/src/redux/modules/shows.js index 7703d78..6f21d46 100644 --- a/src/redux/modules/shows.js +++ b/src/redux/modules/shows.js @@ -1,5 +1,4 @@ import { HYDRATE } from 'next-redux-wrapper'; -import { API_DOMAIN } from '../../lib/constants'; const REQUEST_SHOWS = 'years/REQUEST_SHOWS'; const RECEIVE_SHOWS = 'years/RECEIVE_SHOWS'; @@ -64,15 +63,3 @@ export function receiveShows(artistSlug, year, data) { data, }; } - -export function fetchShows(artistSlug, year) { - return (dispatch, getState) => { - const state = getState().shows[artistSlug]; - if (state && state[year] && state[year].meta && state[year].meta.loaded) return {}; - // console.log('fetching shows', artistSlug, year) - dispatch(requestShows(artistSlug, year)); - return fetch(`${API_DOMAIN}/api/v2/artists/${artistSlug}/years/${year}`) - .then((res) => res.json()) - .then((json) => dispatch(receiveShows(artistSlug, year, json))); - }; -}