All Products
Search
Document Center

:304 status code returned for resource access after using a CDN domain

更新時間:Sep 24, 2021

Overview

This topic describes how 304 status code may occur when you access resources through a CDN domain.

 

Detailed information

When the client successfully sends a request to the server for the first time, the server returns the content to the client with a status code of 200, marks the content modification time, and generates an ETag flag to verify whether the content has been modified. When the same client sends another request, the system will determine whether the object content has been modified during this period based on the ETag value specified in the request. If it has not been modified, 304 status code is returned. The client loads the cached content directly. If the file content is modified, the latest content is returned to the client with the latest file modification time and ETag. Example status code return 304:

  1. This is the first time that the browser client accesses an image. When the request is successful, the server returns 200 status code. The Response Header contains the Last-Modified and ETag fields.

  2. When a client initiates a request for the modified content, the ETag value and the Last-modified value of the modified content will be added to the request header. The server determines whether the modified content has been modified based on the ETag and Last-modified values, as shown in the following figure. If the content is not modified, OSS returns the 304 status code. If the content is modified, OSS returns the latest content to the client. Status code, the value is 200.

  3. Therefore, some server-related log files, CDN log files, and OSS log files may have a 304 status code. This indicates that the content already exists in the cache. And during this period, the content has not been modified. If you want to update the cache, you can press ctrl + f5 the client clears its cache and resends the request to the server. The server returns the request content with the status code of 200.

 

Applicable to

  • CDN