Force Your Page to Always Load From the Server, Not the Web Cache

Have you ever made a change to a website page only to then look in confusion and dismay when the changes are not reflected in the browser? Perhaps you forgot to save the file or didn't actually upload it to the server (or uploaded it in the wrong place). Another possibility, however, is that the browser is loading the page from its cache rather than the server where the new file is sitting.

If you are concerned about your web pages caching for your site's visitors, you can tell the web browser not to cache a page, or indicate how long the browser should cache the page.

Illustration of webpage loading graphic
Andranik Hakobyan / Getty Images

Forcing a Page to Load from the Server

You can control the browser cache with a meta tag:



Setting the Expires to

-1

tells the browser to always load the page from the web server. You also can tell the browser how long to leave a page in cache. Instead of -1, enter the date, including the time, that you would like the page to be reloaded from the server. Note that the time should be in Greenwich Mean Time (GMT) and written in the format, dd Mon yyyy hh:mm:ss

Warning: This May Not Be a Good Idea

You may think that turning off the web browser's cache for your page may make sense, but there is an important and useful reason sites are loaded from cache: to improve performance.

When a webpage first loads from a server, all the resources of that page must be retrieved and sent to the browser. This means that an HTTP request must be sent to the server. The more requests a page makes for resources such as CSS files, images, and other media, the slower that page will load. If a page has been visited before, the files are stored in the browser's cache. If someone visits the site again later, the browser can use the files in the cache instead of returning to the server. This speeds up and improves site performance. In an age of mobile devices and unreliable data connections, fast loading is imperative. After all, no one has ever complained that a site loads too fast.

Bottom line: When you force a site to load from the server instead of the cache, you affect performance. Therefore, before you add these meta tags to your site, ask yourself if this is truly necessary and worth the performance hit that the site will take as a result.

In most web browsers you can force a one-time page load from the server by holding down the shift key while clicking on the Reload or Refresh button.

Format
mla apa chicago
Your Citation
Kyrnin, Jennifer. "Force Your Page to Always Load From the Server, Not the Web Cache." ThoughtCo, Sep. 8, 2021, thoughtco.com/force-page-load-from-server-3466696. Kyrnin, Jennifer. (2021, September 8). Force Your Page to Always Load From the Server, Not the Web Cache. Retrieved from https://www.thoughtco.com/force-page-load-from-server-3466696 Kyrnin, Jennifer. "Force Your Page to Always Load From the Server, Not the Web Cache." ThoughtCo. https://www.thoughtco.com/force-page-load-from-server-3466696 (accessed March 29, 2024).