Why is squid good for REST architectures?

Tag: optimization , rest , caching , squid Author: lingjin88 Date: 2009-11-12

In this article, it is argued that Use Memcache if you frequently fetch random entities from a database, and Squid if you use a REST architecture. Please explain why (with regard to Squid).

Best Answer

REST is all about http and resources.

squid can be used as a reverse proxy, so it will take load from the webserver. the server side can set some expires http header to indicate the timewindow for caching.

this said, the caching is done mainly over standard http headers, therefore its closer to rest styles architecture than caching db queries.

Other Answer1

Memcache is a distributed object store - it's up to you to put objects in and out of this. It's a general purpose cache for any usage.

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

So in summary, memcache is general purpose, Squid is for caching the results of a URL.

Other Answer2

Squid (being a proxy & cache) can effectively be used with REST end-points. In REST, the resources are (supposed to) to be explicitly transferred with ETAG/Last-Modified headers in order to facilitate caching.

Furthermore, many operations in REST are (supposed to) be idempotent (repeat without further side-effects): that's a perfect situation for Squid. It can act alone on these operations without bothering the application server.

Other Answer3

Rest uses the http verbs for their correct actions, i.e. GET is always non-destructive. Urls are also consistantly named. This means http caching in Squid can be used for performance benefit without relying on the underlying programming technology (ASP MVC, Rails, CouchDB, etc.)