He simply writes "Hello Wo...">

Update vs Update

I have this script

<?php header("Expires: Sat, 11 Jun 2011 00:00:00 GMT"); echo "Hello World"; ?> 

He simply writes "Hello World" and sets the cache expiration date next Saturday.

Now, when I load this page into FireFox and press the reload button, it makes a new request to the server to load the page, instead of just serving it from the cache (I think to make sure that last-modified is still valid).

However, if I put my cursor in the address bar and press Enter , FireFox will serve the contents from the cache.

Why is this so? Why in the first case (reboot) it makes a request to the server, but in the second case (update, I think?) Does it serve from the cache?

+6
source share
2 answers

I think the terms “update” and “reboot” are basically synonymous. I see this line in RFC 2616 that describes HTTP / 1.1 caching, which gives a slight difference:

You cannot use an expiration time to force a user agent to refresh its screen or reload a resource

In other words, perhaps you could say that the update is available for displays and the reboot is available for resources. But since the main use of browsers for resources is displayed, I see no difference.

Here is a short entry on the terms of the developer who was managing the browser cache. The terms he prefers are as follows:

  • load: press Enter in the address bar; click on links
  • reload: F5 ; Ctrl + R ; toolbar update button; Menu → Update
  • hard reset: Ctrl + F5 ; Ctrl + Shift + R

(A hard reboot causes the browser to bypass its cache. For Firefox, you hold down the Shift button and press the reload button. Wikipedia has a list of how to do this for regular browsers. You can check its effect on this page .)

To answer the question of how Firefox decides when to update, here is how the link explains this:

  • load: the request is not executed until the expiration of the cached resource
  • reload: the request contains If-Modified-Since and Cache-Control: max-age=0 headers, which allow the server to respond with 304 Not Modified , if applicable
  • hard reload: the request contains the headers Pragma: no-cache and Cache-Control: no-cache and will bypass the cache
+18
source

When people refresh the page, they usually expect to see new results, so caching the entire page does not make much sense.

+2
source

Source: https://habr.com/ru/post/889783/


All Articles