What is the purpose of the & rnd = parameter in HTTP requests?

all!

Why do some web applications use the http-get parameter "& rnd ="? What is the purpose? What problems are solved with this tag?

+6
source share
4 answers

This can be done to ensure that the page / image / everything that was not taken from the user's cache. If the link is different every time, then the browser will receive it from the server, and not from the cache, providing its latest version.

You can also track people's progress through the site. Best explained a little story:

  • A user visits example.com. All links have the same random number (say 4).
  • The user opens the link in a new window / tab, and the link is page2.php? rnd = 4. All links on this page are given by a random number 7.
  • The user can click the page3.php link from the original tab or the new one, and the analytics software on the server can determine which one has rnd = 4 or rnd = 7.

All we can do is offer opportunities. There is no standard reason to put rnd = in the URL, and we cannot know the motives for website design without seeing the server software.

+7
source

Internet Explorer and other browsers will read the image URL, download the image and store it in the cache.

If your application will regularly update the image and therefore want your users to not see the cached image, the URL should be unique every time.

Therefore, adding a random line ensures that it will be unique and will be loaded into the cache every time.

+6
source

This is almost always for cache enumeration.

+4
source

As suggested by others. This behavior is typically used to avoid caching issues when invoking a page that returns dynamic content data.

For example, let's say you have a page that has current user information, such as "mysite.com/CurrentUserData". Now, when you first call this page, user data will be returned as expected, but depending on the time and cache settings, the second call may return the same data - even if the expected data can be updated.

The main reason for caching is, of course, optimizing the speed of frequent requests. But in the case when this is not required, adding a random value as a parameter to the query string is known to be a widely used solution.

There are other ways around this problem. For example, if you were making an Ajax request with javascript / jQuery. You can set the cache to false in your call ...

$.ajax({url: 'page.html', cache: false}); 

You can also change it for all page calls when loading a document using ...

 $.ajaxSetup({cache: false}}); 

If you were to run an MVC application, you can even disable caching in management methods with an attribute like this ...

 [OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")] public ActionResult NonCacheableData() { return View(); } 

(thanks to quick copy and paste from here )

I dare to say that in IIS there are also settings that you could apply to get the same effect, although I have not been this far.

+2
source

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


All Articles