Skip to content

Commit

Permalink
Disable caching on most fetch requests
Browse files Browse the repository at this point in the history
  • Loading branch information
switz committed Sep 19, 2023
1 parent 450b825 commit 595d76e
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/app/(main)/(secondary)/today/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => ({
Expand Down
2 changes: 1 addition & 1 deletion src/app/queries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Artist } from '@/types';

export const fetchArtists = async (): Promise<Artist[]> => {
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) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ShowsColumn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const fetchShows = async (slug?: string, year?: string): Promise<ArtistShows | u
if (!slug || !year) return undefined;

const parsed: ArtistShows = await ky(`${API_DOMAIN}/api/v2/artists/${slug}/years/${year}`, {
next: { revalidate: 60 * 5 },
cache: 'no-cache',
}).json();

return parsed;
Expand Down
2 changes: 1 addition & 1 deletion src/components/YearsColumn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const fetchYears = async (slug?: string): Promise<Year[]> => {
if (!slug) return [];

const parsed = await ky(`${API_DOMAIN}/api/v2/artists/${slug}/years`, {
next: { revalidate: 60 * 5 },
cache: 'no-cache',
})
.json<Year[]>()
.catch(() => {
Expand Down
13 changes: 0 additions & 13 deletions src/redux/modules/shows.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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)));
};
}

0 comments on commit 595d76e

Please sign in to comment.