When I reload a website created using express delivery, I get a blank page with Safari (not Chrome), because the NodeJS server sends me a status code of 304.
How to solve this?
Of course, this might also just be a Safari problem, but it actually works fine on all other sites, so this is also a problem on my NodeJS server.
To generate pages, I use Jade with res.render .
Update: It seems this problem occurs because Safari sends 'cache-control': 'max-age=0' on reboot.
Update 2: I now have a workaround, but is there a better solution? Workaround:
app.get('/:language(' + content.languageSelector + ')/:page', function (req, res) { // Disable caching for content files res.header("Cache-Control", "no-cache, no-store, must-revalidate"); res.header("Pragma", "no-cache"); res.header("Expires", 0); // rendering stuff hereโฆ }
Update 3: So, the full piece of code is currently:
app.get('/:language(' + content.languageSelector + ')/:page', pageHandle); function pageHandle (req, res) { var language = req.params.language; var thisPage = content.getPage(req.params.page, language); if (thisPage) { // Disable caching for content files res.header("Cache-Control", "no-cache, no-store, must-revalidate"); res.header("Pragma", "no-cache"); res.header("Expires", 0); res.render(thisPage.file + '_' + language, { thisPage : thisPage, language: language, languages: content.languages, navigation: content.navigation, footerNavigation: content.footerNavigation, currentYear: new Date().getFullYear() }); } else { error404Handling(req, res); } }