{"id":464,"date":"2008-03-03T18:46:13","date_gmt":"2008-03-04T00:46:13","guid":{"rendered":"http:\/\/www.mooreds.com\/wordpress\/archives\/000464"},"modified":"2008-03-03T18:46:13","modified_gmt":"2008-03-04T00:46:13","slug":"squid-notes-a-fine-web-accelerator","status":"publish","type":"post","link":"https:\/\/www.mooreds.com\/wordpress\/archives\/464","title":{"rendered":"Squid Notes: A fine web accelerator"},"content":{"rendered":"<p align=\"left\" style=\"margin-bottom: 0in\">I recently placed squid in front of an Apache\/Tomcat based web application to serve as a web accelerator.  We could have used <a href=\"http:\/\/httpd.apache.org\/docs\/1.3\/mod\/mod_proxy.html\">Apache&#8217;s mod_proxy<\/a>, but squid has the ability to federate and that was considered valuable for future growth.  (Plus, <a href=\"http:\/\/meta.wikimedia.org\/wiki\/Wikimedia_servers\">Wikipedia uses squid<\/a>, and it has worked out pretty good for them so far.)  I didn&#8217;t find a whole lot of other options&#8211;<a href=\"http:\/\/varnish.projects.linpro.no\/\">Varnish looks good<\/a>, but wasn&#8217;t quite documentation and feature rich enough.<\/p>\n<p style=\"margin-bottom: 0in\">However, when the application generates a page for a user who is logged in, the content can be different than if the exact same URL is visited by a robot or a user who is not signed in.  It&#8217;s easy to tell if a user is signed in, because they send cookies.  What was not intuitive was how to tell Squid that pages for logged in users (matching a certain header, or a certain URL pattern) should always be referred to Tomcat.  In fact, <a href=\"http:\/\/www.mail-archive.com\/squid-users@squid-cache.org\/msg51734.html\">I asked about this on the mailing list<\/a>, and it doesn&#8217;t seem as if it is possible at all.  Squid caches objects at the page level, and can&#8217;t cache just pieces of a page (like I believe, among others, <a href=\"http:\/\/wiki.opensymphony.com\/display\/CACHE\/JSP+Tags\">OSCache can<\/a>).<\/p>\n<p style=\"margin-bottom: 0in\">I compromised by deleting the cached object (a page, for example) whenever a logged in user visits it.  This forces squid to go back to the origin server, guaranteeing that the logged in user gets the correct version.  Then, if a non logged in user requests the page, squid again goes back to the origin server (since it doesn&#8217;t have anything in its cache).  If a second logged in user requests the same page, squid serves it out of cache.  It&#8217;s not the best solution, but it works.  And non logged in users are such a high proportion of the traffic that squid is able to serve a fair number of pages without touching the application.<\/p>\n<p>Overall I found Squid to be pretty good&#8211;even with the above workaround it was able to take a substantial amount of traffic off the main application.  Note that Squid was designed to be a forward proxy (for example, a proxy at an ISP caching commonly requested pages for that ISPs users), so if you want to use it as a web accelerator (in front of your website, to increase the speed of pages you create), you have to ignore a lot of the documentation.  The <a href=\"http:\/\/wiki.squid-cache.org\/SquidFaq\">FAQ<\/a> is a must read, especially the <a href=\"http:\/\/wiki.squid-cache.org\/SquidFaq\/ReverseProxy\">section on reverse proxying<\/a> and the <a href=\"http:\/\/wiki.squid-cache.org\/SquidFaq\/SquidLogs\">logs section<\/a>.<\/p>\n<p style=\"margin-bottom: 0in\">[tags]proxy, squid,increasing webapplication performance[\/tags]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I recently placed squid in front of an Apache\/Tomcat based web application to serve as a web accelerator. We could have used Apache&#8217;s mod_proxy, but squid has the ability to [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,20],"tags":[],"class_list":["post-464","post","type-post","status-publish","format-standard","hentry","category-http","category-web-applications"],"_links":{"self":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/464","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/comments?post=464"}],"version-history":[{"count":0,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/464\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/media?parent=464"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/categories?post=464"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/tags?post=464"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}