What is a 304 Not Modified Response?
A 304 Not Modified response is a crucial part of web communication, designed to make browsing faster and more efficient.
When a user’s browser requests a page that they have visited before, it often includes a timestamp to check if the content has changed since it was last loaded. If the content hasn’t changed, the server sends back a 304 status code and will retrieve the cached version of the webpage from your local storage. For crawlers like Googlebot it means that there is no need to recrawl the page as nothing has changed.
How It Works
When visiting a website, the browser or a web crawler makes a request for a specific page or resource. Here’s a step-by-step breakdown of what happens:
- The first time you request a page, the server sends you the content along with a hash code called an ETag (which is like a digital fingerprint of the content) and a status code of 200 OK.
- The browser notes the time when it got the page and keeps track of the ETag.
- When the page is visited again, the browser asks the server if the content has changed since it last checked. This is done through a “conditional request,” where the browser includes the ETag and the date of the last request.
- The server looks at the ETag and the date:
- If the ETag matches: This means the content hasn’t changed. The server responds with a 304 Not Modified status code, telling your browser to use the cached version.
- If the date is recent: If the content hasn’t changed since the date provided, the server also responds with a 304 Not Modified status code.
- When the browser gets the 304 Not Modified response, it simply displays the cached version of the page, so you don’t have to wait for it to reload.
The Benefits
- Saves Bandwidth and Speeds Up Loading: By sending a 304 status code, the server tells the browser that the cached version of the page is still up-to-date. This means that the browser doesn’t need to download the entire page again, saving bandwidth and speeding up page loading times for users.
- Improves User Experience: Faster loading times means users get to see your content quicker, making your browsing experience smoother and more enjoyable.
- Reduces Server Load: Since the server doesn’t have to resend unchanged content, it can handle more requests and operate more efficiently. This helps in reducing overall server load and improves performance.
- Saves Crawl Budget: While smaller websites may not benefit as much, it is great for larger websites as it tells crawl bots that a page doesn’t have to be recrawled, optimising crawl budget allowing it to update more new and updated pages.
Fixing HTTP 304 Not Modified Requests
When a 304 code is successful, it is invisible to users. However, this code becomes an error when users can see the 304 code. This means there is a communication problem between the browser and server that prevents them from accessing the desired page. More often than not the error will likely have occurred on the user’s end, which means there isn’t much that can be done. Some common reasons for this error include:
- Server configuration issues
- DNS issues
- Computer viruses
- New software
- Corrupted applications
Clear Browser Cache
Sometimes, a browser’s cache can become outdated or corrupted. Clearing the cache forces the browser to fetch the latest version of the content from the server. Simply go to your browser’s settings and clear the cache to start fresh.
Clear DNS Cache
A computer also stores DNS information to speed up website loading times. However, this cached information like browsing data, host names and IP addresses can become outdated.
Clearing your DNS cache can help resolve issues related to outdated or incorrect data. You can usually do this by accessing the following chrome://net-internals/#dns in Google Chrome or running a command in your operating system’s command prompt.
Run a Virus Scan
Occasionally, malware or viruses can interfere with your browser’s functionality. Running a comprehensive virus scan can help identify and remove any malicious software that might be causing problems with how content is being cached or displayed.
Disable Browser Extensions
Some browser extensions can interfere with caching and content loading. Try disabling your extensions one by one to see if any are causing issues. If the problem goes away after disabling a specific extension, you may need to update it or find an alternative.