Skip to content

Commit

Permalink
Add cache buster to data fetch to prevent caching issues
Browse files Browse the repository at this point in the history
  • Loading branch information
FokkoVeegens committed Jan 3, 2025
1 parent 9fc9bc6 commit 24c3af0
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/utils/getData.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import basename from "../../react-config";
let cachedData = null;

const getData = async () => {
if (cachedData) {
return cachedData;
}
const cacheBuster = new Date().getTime(); // Generate a unique timestamp
try {
const response = await fetch(`${basename}data.json`);
const response = await fetch(`${basename}data.json?cacheBuster=${cacheBuster}`);
if (!response.ok) {
throw new Error('Network response was not ok');
}
Expand Down

0 comments on commit 24c3af0

Please sign in to comment.