Lessons

304 response code for caching

The page consists of dozens of files, and 95% of the files can be shared by all pages of the site. Caching was invented to avoid downloading this information every time.

There are 3 caching mechanisms:

  • The “cache-control” or “expires” headers indicate how long the content will be relevant. During this time, the user’s browser uses the saved copy of the file and does not make any requests to the server.
  • Caching via “etag”. The server generates a unique string based on the content and the user’s browser asks each time if the file has changed and provides this string.
  • The title is “Last-Modified”. The server reports the date of the last file change, and the browser asks each time if the file has changed since that time.

When the browser makes a request to the server about whether the file has changed, the server should respond with a 304 code. If this does not happen, then caching does not work. This slows down the loading of the site’s pages.

Instruction [How to set up caching] (/blog/apache_i_nginx_tyuning_bystrodeystviya).

Check your website
It's free and will take from 11 to 45 seconds

We use cookies. By continuing to use the site, you agree to the processing of personal data in accordance with privacy policy. I agree