Why is squid suitable for REST architectures?

This article claims to use Memcache if you often select random objects from the database, and Squid if you use the REST architecture. Please explain why (regarding Squid).

+5
source share
5 answers

REST is all about http and resources.

squid can be used as a reverse proxy , so it will be downloaded from the web server. the server side can set a somewhat expiring http header to indicate a timewindow for caching.

This suggests that caching is mainly done on standard HTTP headers, so it’s closer to the rest architecture than db cache requests.

+3
source

Memcache is a repository of distributed objects - you need to put objects in and out of it. This is a general purpose cache for any use.

Squid is a proxy server and web cache. If everything is through a URL (e.g. REST), then Squid will do the job for free.

So memcache is a general purpose, Squid is for caching URL results.

+6
source

Rest uses http verbs for its correct actions, i.e. GET is always non-destructive. Urls are also called sequentially. This means that HTTP caching in Squid can be used to improve performance without using core programming technology (ASP MVC, Rails, CouchDB, etc.).

+2
source

Squid (which is a proxy server and cache) can be used effectively with REST endpoints. In REST, resources (presumably) should be explicitly passed with ETAG / Last-Modified headers to facilitate caching.

In addition, many REST operations (presumably) should be idempotent (repeat without additional side effects): this is an ideal situation for Squid. He can act independently in these operations without disturbing the application server.

+2
source

(This answer comes ten years after the initial question - but, given that I come across this question in the larger organizations that I consult with, I decided it was useful to explain here.)

When Roy Fielding looked at SOAP , he realized that if HTTP methods (GET, POST , etc.) are used to access and change resources , and not just HTTP for simple remote procedure calls, then other HTTP specifications, such as caching ( RFC-2616 ), may be used. The layered architecture of Fielding illustrates this. That's why he developed REST .

As a proxy server for HTTP caching, Squid is an implementation that can significantly reduce the load on your backend systems, as well as keep cached data up to date.

The standard allows you to determine how long an item can be cached before it is re-checked, and how to make conditional requests, so only new versions are sent in response to a request. All of this client behavior has already been implemented in browsers and in HTTP clients used in major languages ​​such as the Java Apache HttpComponents Client and the accompanying caching library .

Since all of these mechanisms have been clearly defined and implemented to date, their use is actually only a matter of using these components, most of which you may already be using (for example, at the time of writing, Apache HC Components is the default implementation). that comes with SpringBoot - just add the caching library to the assembly).

If you implemented this with MemCache or Redis , you simply reinvent the wheel and will continue to maintain this custom code ever since. And if you do not implement the RFC 2616 equivalent in your code, you will use legacy data with inefficient communication.

0
source

All Articles