Web Caching and Conditional GET Statements

What is Web Caching?

The activity of saving data for reuse, such as a copy of a web page supplied by a web server, is known as web caching.

  • It is cached or saved the first time a user accesses the page, and a cache will deliver the copy the next time a user requests the same page, preventing the origin server from becoming overwhelmed.

  • Web caching techniques dramatically improve page delivery speed and reduce the amount of work required of the backend server.

  • Caching servers can be configured to refresh at predetermined intervals or in response to specified events to guarantee that only the most recent content is cached. (valid for rapidly changing information, such as the news).

  • Caching can help protect against total outages by delivering content that has already been cached while servers are unavailable.

  • Varnish is a subscription-based and service-based solution suite that includes robust web caching.

Proxy Server

A Proxy Server – an intermediary between the source server and the client – performs web caching. When a client requests information (through an HTTP message), the request is routed through a proxy server, which does the following −

  • It first looks to see if the copy is stored locally.

  • If it has, it sends the result to the client directly.

  • Otherwise, it performs the query on behalf of the end host, saves a copy of the response locally, and sends it back to the end host.

ISPs (Internet service providers), Universities, and even corporate offices commonly deploy web caches (or proxy servers) where numerous end hosts are connected to the proxy server.

Advantages of Using a Proxy Server

  • It reduces the time it takes to answer repeated requests. (Especially if there is a more minor bottleneck between the original server and the recipient than between the proxy server and the receiver.)

  • It lowers the cost by reducing the access link bandwidth (at the institution or the office).

  • It reduces the overall amount of Internet traffic.

Web Caching and Conditional GET Statements

What if the material on the source server has been changed, making the proxy server's copy obsolete? Conditional GET statements come into play here.

When a proxy server receives an HTTP request and stores the response locally, it nevertheless requests the source server to see if the item in question has been updated since the proxy server last requested it. The "If-modified-since" field in the "Conditional GET" statement differs from the "Get" statement in that it describes the last time the same request was made.

The HTTP 304 status code informs the proxy server that the content has not been updated. It sends the revised content (if any changes have been made) – HTTP 200 response-message code.

If the Proxy server receives a 304 – "No Modification" reply, it sends the client its local copy. If the item has been modified, the Cache forwards it while also storing it locally, along with the date and time it received it (so that it can ask the original server later for modifications).

An HTTP 304 message does not have a message body for obvious reasons.