Home
/
Website Help
/
304 Status Code - What is it & How to Fix it?

304 Status Code - What is it & How to Fix it?

The 304 “Not Modified” status code is one of these HTTP status codes that you’ve most likely heard of while surfing the internet. Some HTTP codes are more popular and often encountered by visitors like the 404 “Not Found” or 504 “Gateway Timeout” errors. At the same time, others are concealed and working in the background of your browser.

304 status code is one of these. It serves its purpose in the communication between web servers and web clients. Hidden for the end user, it provides instructions on how to load web page resources.

With that being said, HTTP codes are often mistaken for errors regardless of their nature and not handled properly, and the 304 HTTP status code is no exception.

This article will make things clear and provide further insights into what the 304 “Not modified” status is and how to fix errors caused by it.

The HTTP 304 status code, “Not Modified,” tells the client that the requested resource hasn’t changed since the last access. This allows the browser to use its cached version, saving bandwidth and speeding up load times.

Thus, the 304 status code reduces bandwidth usage by instructing browsers when to load cached content and when to download new resources.

How 304 Status Code Works

The following example describes a typical interaction between a web server and a browser involving a 304 response code:

  1. You open a new website: When you visit a website for the first time, the browser sends an HTTP GET request to the server for the desired resource.
  2. The server returns the ETag or Last-Modified header: The server processes the HTTP request and responds with the resource along with HTTP response headers that include “ETag” and/or “Last-Modified.” These headers represent the current state or version of the resource.
  3. Your browser stores these headers and downloads the content: The browser stores the “ETag” and/or “Last-Modified” headers along with the resource in its cache. The content is now cached on your device.
    HTTP Response Code 200
  4. Next time you visit the website: When you revisit it, or the browser needs to revalidate the cached content, it sends a conditional GET request. This request includes the If-None-Match header with the previously stored ETag value and/or the If-Modified-Since header with the previously stored Last-Modified date.
  5. The server evaluates the headers: The server receives the conditional request and checks the resource’s current state against the “ETag” and/or “Last-Modified” date provided by the browser.
  6. The server responds in two different ways based on the evaluation:
    • If the current “ETag” or “Last-Modified” date matches the values provided by the browser (meaning the content hasn’t changed), the server responds with a “304 Not Modified” status code. The browser continues to use the cached content.
    • If the current “ETag” or “Last-Modified” date does not match the values provided (the content has changed), the server responds with a `200 OK` status code. Then, it sends the new version of the resource. The browser updates its cache to save web pages in their latest version, ETag, and/or `Last-Modified` HTTP headers.
How 304 Status Code works

What Is the Difference between 304 and 200 HTTP Status Codes?

The 200 OK and 304 Not Modified status codes are two possible outcomes of the same client requests sent to a web server. While both codes represent a successful interaction, they provide different instructions on handling the requested resource.

  • The 200 OK response code contains the body of the requested resource (HTML document, JSON file, image, etc.)
  • The 304 Not Modified response has no body and only contains headers. These headers inform browsers that they have an up-to-date version of the resource they requested, and they can use their stored cache version.
  • The 200 response code disregards the browser’s cached resources and provides the latest resource version.

How to Fix HTTP 304 Status Code

An outdated cached resource or a browser misconfiguration may prevent loading the cached browsing data. In this case, you may stumble upon errors while visiting web pages.

Thus, you should focus on solving these kinds of issues instead of trying to fix every 304 Not Modified HTTP code.

Below, you’ll find the most common and effective solutions.

Clear Your Browser Cache

Often, outdated or corrupted browser data can negatively impact how your browser communicates with a web server. As a result, it can spit out all kinds of errors.

In many cases, clearing your browser’s cache resolves such errors. Follow the steps below to delete the cache on Chrome.

  1. Open the kebab (three dots) menu and select Clear browsing data.
    How to open Clear Browsing Data options in Google Chrome


  2. To delete cached images and files, tick the box for Cached images and files. Optionally, you can also delete cookies and browsing history.
  3. Confirm your choice by pressing Clear Data.
    Options for Clear browsing data in Google Chrome
  4. Reload the requested page to see if the error is resolved.

Flush the DNS Cache

Your computer also stores DNS cache, which consists of the DNS settings of previously visited websites. An outdated DNS cache can lead to all kinds of trouble when visiting web pages.

Flush the DNS cache to get rid of expired or corrupted DNS information. To do that, you’ll have to use the Terminal on Mac or Linux and Command Prompt on Windows.

Let’s take macOS, for example. To clear the DNS cache, type the following command in Terminal.

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

After running the command, you’ll be prompted to provide your administrator (sudo) password.

Flushing DNS cache on Mac through Terminal

NOTE! You must have administrator (sudo) privileges to flush the DNS cache on either operating system (OS).

Follow the guides below for step-by-step instructions on clearing the DNS cache on different operating systems (OS).

Disable Browser Extensions

Browser extensions are great for extending the basic functionality of all major browsers. But on rare occasions, they may prevent the cached resource from loading correctly.

Therefore, you could deactivate your browser’s extensions to check if they cause any disturbance.

Follow the steps below to turn off Chrome extensions. The process on other browsers is similar.

  1. Open the kebab menu > Extensions > Manage Extensions.
    How to open Extensions in Google Chrome
  2. Click on the ON/OFF slider to deactivate an extension. Alternatively, you can delete unused or outdated extensions with the Remove button.
    Disabling extensions in Google Chrome
  3. Next, revisit the web page that produced errors. If the error persists, repeat the process until the page loads successfully.

Check for Redirects in the .htaccess File

Incorrect redirect instructions can prevent your browser from correctly processing a 304 HTTP response code from a website. Thus, if you are the website owner, you should inspect your server configuration file containing redirect directives.

This file is .htaccess in Apache, the most popular web server application. Here is how to inspect it.

  1. Access your website files via FTP or File Manager. If you are a SiteGround user, go to Site Tools > Site > File Manager.
  2. Open your website’s root directory. Usually, it is yourdomain.com/public_html.
    How to access a website root folder in Site Tools
  3. Find the .htaccess file and edit it.
    Editing an .htaccess file


  4. Look for any redirect rules. They are usually placed at the top of the .htaccess file. Remove them to test if they prevent you from loading the website.
    Redirects in .htaccess

IMPORTANT! Make a backup copy of your .htaccess file before editing it. This way, you can safely restore it if you delete a critical directive.

Change the DNS servers

Computers obtain websites’ IP addresses from DNS servers. If the DNS server communication is broken, your computer may not properly handle a 304 status code. It could be caused by a wrong DNS server address or a temporary problem in your designated DNS server.

Change the default DNS servers with other public DNS servers. For example, you can switch to Google’s DNS servers if your ISP uses custom ones.

Google DNS Servers
8.8.8.8
8.8.4.4

The exact way of changing the DNS servers depends on your operating system (OS). Below, you’ll find the steps for Windows and Mac.

Mac

  1. Open System Settings > Network.
  2. Select your active network and click on Details.
    Network settings in Mac
  3. Open the DNS tab.
  4. Click on the + sign.
  5. Type the new DNS server address in the highlighted field.
  6. Press OK.
    Changing the DNS servers on Mac
  7. Reload the problematic page to see if the error is gone.

Windows

  1. Open the Windows menu.
  2. Type “control panel” in the search bar.
  3. Click on the Control Panel icon that appears as the first search result.
    Control Panel in Windows
  4. Select Network & Internet > Network and Sharing Center.
    Network and Internet settings in Windows
  5. Click on your active network.
  6. A pop-up window will appear. Press the Properties button.
    Network properties in Windows
  7. Highlight the item Internet Protocol Version 4 (TCP/IPv4) and select Properties.
  8. Choose the option Use the following DNS server addresses.
  9. Type the primary DNS server address in the field Preferred DNS server.
  10. Enter the secondary DNS server address in the field Alternate DNS server.
  11. Confirm the settings by clicking OK.
    Changing the DNS servers in Windows


Is HTTP 304 ” Not Modified” Status Code Bad?

No, the HTTP 304 “Not Modified” status code is not a bad code. It doesn’t point out anything wrong with your browser or a site’s web server. In fact, it doesn’t represent any problem and is not an error code.

On the contrary, its purpose is to improve the user experience for website visitors. Instead of downloading the contents every time, web browsers can use their cached data to render web pages faster. Thus, the 304 status code can save bandwidth usage, time, and server resources.

That being said, many online tutorials treat the 304 status as one of the error codes and focus on fixing it as if the goal is to get rid of it. That is not right, and you shouldn’t aim to eliminate the 304 status code. In fact, you are not likely to see it on your screen at all.

However, different cache-related issues and browser/device misconfigurations, indirectly related to the HTTP 304 status code, can hinder your connection to specific websites.

Wrap Up

The HTTP 304 status code is an integral part of the web’s caching mechanism that generally improves browsing speed and efficiency. While it’s not inherently problematic, misconfigurations can lead to issues with content not being updated correctly.

By following the troubleshooting methods outlined above, you can resolve most issues related to the 304 status code and ensure you see the most up-to-date web content.

Share This Article