From b344106c19b991d63d01989204edc7f144d324f1 Mon Sep 17 00:00:00 2001 From: ssyyhhrr <808648@student.derby-college.ac.uk> Date: Mon, 20 Mar 2023 11:40:12 +0000 Subject: [PATCH] No Cache Fix --- app.js | 9 ++++++++- assets/js/main.js | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index 83450d5..39f6956 100644 --- a/app.js +++ b/app.js @@ -226,7 +226,14 @@ function server() { app.enable("trust proxy") app.use(express.urlencoded({ extended: true })) - app.use(express.static("assets")) + app.use(express.static("assets", { + setHeaders: function(res, path, stat) { + // Set cache control headers + res.set('Cache-Control', 'no-cache, no-store, must-revalidate'); + res.set('Pragma', 'no-cache'); + res.set('Expires', '0'); + } + })) app.use(favicon('assets/favicon.ico')) app.use(morgan("combined")) diff --git a/assets/js/main.js b/assets/js/main.js index 8968596..0468bc5 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -526,7 +526,7 @@ document.addEventListener('DOMContentLoaded', () => { } let scores = JSON.parse(localStorage.scores) fillStats(stats, scores) - fetch(`${window.location.href}/drivers.json?nocache=${new Date().getTime()}`).then(res => { + fetch(`${window.location.href}/drivers.json`).then(res => { res.json().then(result => { driversObj = result Object.entries(result).forEach(driver => {