Cache, Cookies, Browser Session: How to Use Them in Software Testing

No votes yet.
Please wait...

Every QA engineer who offers web application testing services should be familiar with such terms as cache, cookies, and browser session.

Frequently, many questions arise when we meet such terms.

Let’s analyze each of these terms, to completely understand their meaning, study their fields of usage, and a process of their usage (according to a browser you are using).

Cookies, Session and Cache

Cookies, Session and Cache

Cookies

Cookies are a certain amount of information that is created by a server when a user visits a web page, and it’s saved on a user’s PC in the form of a separate document.

Cookies mainly store identification information, user data, features, and settings that have been chosen while interacting with a page and also, other similar service data.

If cookies are supported by a browser, then every next request will make all information transfer from a user to a server. What’s the use of all these data?

Identification info is commonly used by a server to:

  • Gather and analyze the statistic;
  • Track session proceeding (we’ll talk about this term further);
  • Authenticate a user (otherwise, you will need to write a login and a password every time);
  • Personalize the settings chosen by a client at all requests (for example, products’ language or certain settings in a shopping cart).

From a technical view, cookies are text documents of a small size. The maximum size of a cookie file is 4096 bytes.

The cookie document comprises the following things:

  • Its name;
  • Value (data, transferred to a server and must be processed during the request);
  •  The domain that belongs to this cookie and that receives it;
  • URL-path in the space of this domainб where a certain cookie is valid for it;
  • Expiration date. Cookies are saved only for a certain time range, that is established for every cookie separately. It may be a certain day, time or session value in the case when cookies are saved until the end of a current session;
  • HTTP (it’s assigned only in the case when cookies will be used only by HTTP);
  • Security (it’s cookie transfer only through secure HTTPS);
  • Size of cookie documents in bytes.

Session

Web servers have one important feature that is expressed in a way that they can’t recognize where requests come from every time (from the same browser or from the different one).

This happens because HTTP protocol doesn’t allow tracking the course of such states and therefore, to support permanent connection with a user.

Every request is processed separately, apart from the previous ones.

This issue may be resolved by a browser session – a way of tracking the requests from one browser, that is able to save some variables while moving between the pages of a web product.

When a session starts, a server creates a document where the client’s data, his/her actions ad events that happened during one session are created. This can be website viewing, actions with page content, transaction making, and so on.

A new session can’t start until the previous one ends.

The previous session will end only in the case if one of the following actions will be performed (it depends on settings):

  • A browser will be closed;
  • If a user hasn’t done any actions for a certain amount of time;
  • At established time of a day (for example, in the evening or at night).

Cache

It’s a well-known fact that a website should be rapidly loaded so that we can work well on the net.

An increase in a page response time can make a user simply close it and move to another one, more optimized. Therefore, a developer shouldn’t afford this.

The overall complexity of the situation is that after every page update, a server transfers a browser quite a big amount of information. And this obviously has a negative impact on website speed. Cache has been created to resolve this issue and optimize web software.

For example, your Internet network works more slowly than a computer. With the help of a cache, a browser saves certain amount of data on a client’s local PC.

As a result, if there is a need in the second loading of the same information, the necessary data will be simply loaded from PC memory, not connecting to the net.

And the page will naturally be loaded much faster in such a case.

What is commonly saved in the cache? Pages of the same website usually have the same design, and therefore, there are website elements that are duplicated on different web pages.

To not transfer the same capture during each transfer, it’s locally saved to cache files and is loaded from a user’s hard drive, not through a server, after updating.

Besides logos, text messages, video files, and sound can be also cached.

Browser cache has a limited size. Its maximum size can be set. When cache memory is full, the data that were not used for a longer time, are deleted, thereby providing the space for new parts.

After analyzing such terms as “session”, “cache” and “cookies”, let’s move to their direct usage.

A common user will be able to switch on/off, edit or delete cookies, clear cache, and find the data on his/her PC.

How to clear the cache on a PC?

First, you should pay attention to the browser you are using.

It’s important to remember that cache of the same web product is located in different directory files C:\Users\Admin\AppData\Local\ in different browsers.

If you can’t find such a folder on your PC, you need just to activate hidden files showing in the Settings.

Every browser creates its file folder with a cache in this directory.

Let’s talk about the most popular browsers:

  • Internet Explorer
    – C:\Users\Admin\AppData\Local\Microsoft\Windows\INetCache\
    – C:\Users\Admin\AppData\Local\Microsoft\Windows\Temporary Internet Files\
  • Google Chrome
    C:\Users\Admin\AppData\Local\Google\Chrome\User Data\Default\Cache
    C:\Users\Admin\AppData\Local\Google\Chrome\User Data\Profile 1\Cache
  •  Safari
    ~/Library/Caches/com.apple.Safari/
  • Mozilla Firefox
    C:\Users\Admin\AppData\Local\Mozilla\Firefox\Profiles\zxcvb5678.default\cache2\entries
  • Opera
    C:\Users\Admin\AppData\Local\Opera Software\Opera Stable\Cache.

You can delete the entire information from a website, clear cache, and cookies directly in a browser.

You can use a special function that can be activated in the Settings.

Every browser has its process of doing this, so let’s analyze the process of cache clearing more thoroughly:

  • Safari. “Develop” – “Empty cache” (develop’s menu must be active in the application’s settings;
  • Google Chrome. “Settings” – “More tools” – “Clear browsing data” – “Cached images and files” – “Clear data”;
  • Opera. “Settings” – “Privacy and Security” – “Clear browsing data” – “Clear browsing data”.
  • Internet Explorer. “Tools” – “Safety” – “Delete browsing history” – Temporary Internet files and website files – “Delete”;
  • Mozilla Firefox. “Options” – “Privacy & Security” – “Cookies and site data” – “Clear data” – “Clear”.

You can also use another method to clear cache, not using its Settings. It’s hotkeys: Ctrl+Shift+Del – for multiple browsers and ⌥(Option)+⌘(Command)+E – for Safari on Mac.

How to find cookies in different browsers?

For example, to find cookies in Chrome, you should take the next steps:

  1. Go to the browser’s menu;
  2. Choose the “Settings” tab;
  3. “Additional” tab ;
  4.  “Website’s settings”;
  5.  Then you will see “Cookie files” tab where you can configure them, namely :
  • Block/disable cookies;
  • Activate/enable (block/disable) the function of cookies saving with the help of a slider;
  • View the overall data of every separate document;
  • Activate/enable the function of cookie deletion when a browser is closed;
  • Delete cookies for certain websites;
  • View the whole list of saved cookies files, find necessary cookies in a list.

As for Internet Explorer 11, it has another path: “Browser menu” – “Browser settings” – “Privacy” –“Websites/Additional”. You can work with cookie files of chosen websites here.

To view the value of saved settings of a certain website, you should use developer tools (F 12 button). The “Network” tab contains the lists of requests and “Cookie files” contains their data.

Web development is an extremely rapid process. Sometimes a website is updated several times a day.

Every tester should remember that he/she must clear the cache before he/she starts testing the product.

If he/she doesn’t do this, a web page can be loaded from cache and he/she won’t see the updates that have been made.

The session process includes browser’s identification and processing of the requests within one session.

Variables from the previous requests are used while doing his. All information about the session is mainly saved on a server and are hidden from a user.

If a QA engineer knows the time when the session will end and can foresee the website’s behavior after its termination, he/she will easily write several scripts for testing.

Frequently, you should switch on cookies, to make a website work properly. In this case, you can test a product in two ways: with the cookies switched on or off.

The third way of testing is to manually edit the cookies, using both valid and invalid information.

Cookie files contain user’s personal authorization data.

After using certain tools for changing these data, a tester can find if it’s possible to provide access to the account of another visitor, by editing the cookies. Such type of testing is called security testing.

When you first read about such things as cache, browser session, and cookies, everything seems to be complex and tricky, but after studying the terms and using the received knowledge in practice, you can see that it’s actually quite simple.

Leave A Comment