[squid-users] Flexible configurations

From: Joaquim Pedro Fran�a Sim�o <osmano807_at_gmail.com>
Date: Sun, 20 Jun 2010 14:14:23 -0300

I'd like to see the squid supporting something that Varnish is very good.
An example would be to remove cookies from all images

# strip the cookie before the image is inserted into cache.
sub vcl_fetch {
 if (req.url ~ "\.(png|gif|jpg|swf|css|js)$") {
  unset obj.http.set-cookie;
}

This is very good and very open to the settings.
Another thing is also interesting to make the varnish is to normalize
the header accept-encoding

if (req.http.Accept-Encoding) {
   if (req.url ~ "\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$") {
       # No point in compressing these
       remove req.http.Accept-Encoding;
   } elsif (req.http.Accept-Encoding ~ "gzip") {
       set req.http.Accept-Encoding = "gzip";
   } elsif (req.http.Accept-Encoding ~ "deflate") {
       set req.http.Accept-Encoding = "deflate";
   } else {
       # unkown algorithm
       remove req.http.Accept-Encoding;
   }
}

To do this in Squid, had to apply a patch, or is in-built code, and I
can not change the time I want without recompiling (and still is not
as simple as varnish)
In src/client_side.c:

+ /*
+ * Normalize Accept-Encoding Headers sent from client
+ */
+ if(httpHeaderHas(&request->header,HDR_ACCEPT_ENCODING)) {
+ String val =
httpHeaderGetByName(&request->header,"accept-encoding");
+ if(val.buf) {
+ if(strstr(val.buf,"gzip") != NULL) {
+
httpHeaderDelByName(&request->header,"accept-encoding");
+
httpHeaderPutStr(&request->header,HDR_ACCEPT_ENCODING,"gzip");
+ } else if(strstr(val.buf,"deflate") != NULL) {
+
httpHeaderDelByName(&request->header,"accept-encoding");
+
httpHeaderPutStr(&request->header,HDR_ACCEPT_ENCODING,"deflate");
+ } else {
+
httpHeaderDelByName(&request->header,"accept-encoding");
+ }
+ }
+ stringClean(&val);
+ }

Complete patch:
http://victori.uploadbooth.com/patches/squid-headers-normalization-v4.patch

I do not know if it was so clear, but that was what I wanted in squid.
The reason I do not use varnish, you do not want a reverse proxy, but
proxy to cache.

-- 
osmano807
Joaquim Pedro
Received on Sun Jun 20 2010 - 17:14:49 MDT

This archive was generated by hypermail 2.2.0 : Mon Jun 21 2010 - 12:00:03 MDT