Fixing Cache Issues When Upgrading Web Versions or Technologies

Tiempo de lectura: < 1 minuto

A few weeks ago, I updated a PHP website to Next.js with React, and to my surprise, when I loaded the page, it displayed the PHP version without loading the previous resources correctly because they did not exist.

To solve this issue, we can try loading a file that was included in the previous website and force a reload of the website within that file with a parameter that forces loading the version without using cache.

For example:

window.location.href = 'https://www.website.com/?a=1';

This way, it will load the initial version with a parameter that will force getting the website again.

Another interesting option is to add the old CSS and JS resource files in the same folders as the previous version would load from, so that users don’t experience a sudden break. This way, they would see the previous website, but when the view is invalidated, it will load the new resources.

Leave a Comment