Skip to content

Instantly share code, notes, and snippets.

@tongueroo
Created March 22, 2009 10:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tongueroo/ca5ef043fdfb89a5b143 to your computer and use it in GitHub Desktop.
Save tongueroo/ca5ef043fdfb89a5b143 to your computer and use it in GitHub Desktop.
**** UPDATE
Adding this, to the simple.vcl config enabled caching in the app #2.
sub vcl_fetch {
unset obj.http.set-cookie;
unset obj.http.expires;
set obj.ttl = 1m;
deliver;
}
**********************************************************************
######################################################################
# TOC
# SETUP
# * how im starting varnish
# * simple.vcl config file
# DESCRIPTION OF PROBLEM
# * cant get it to cache with one app but can with another with the same config settings...
# QUESTIONS
######################################################################
######################################################################
# how im starting varnish
######################################################################
root@walle /opt/local/etc/varnish $ varnishd -a localhost:6081 -T localhost:6082 -F -f simple.vcl
######################################################################
# simple.vcl config file
######################################################################
backend default {
.host = "127.0.0.1";
.port = "4567";
# .port = "3000";
}
sub vcl_recv {
# C{
# printf("Hello");
# }C
unset req.http.cookie;
}
sub vcl_fetch {
unset obj.http.expires;
set obj.ttl = 1m;
}
######################################################################
# description of problem
######################################################################
I set up a very simple app to test varnish and its caching with the simple app, its
a small sinatra app... It appears to be caching just fine. Using the config above with with
port 4567 for the backend.
Heres the requests Im issuing and the varnishlog:
https://gist.github.com/915456f2b48e05cf4830 app #1
Im trying to test a rails app. But cant get it to cache. Same config as above with port
3000.
Heres the requests Im issuing and the varnishlog:
https://gist.github.com/1d8f72e2d4ef1feaba3c app #2
I can see from varnishlog from app #1 that does a look up and successfully retreives from the
cache...
lines 77 to 80
7 VCL_call c recv lookup
7 VCL_call c hash hash
7 Hit c 738911632
7 VCL_call c hit deliver
The second varnishlog from app #2 does a HitPass? And cant find the data in the cache?
lines 97 to 100
7 VCL_call c recv lookup
7 VCL_call c hash hash
7 HitPass c 1799430110
7 VCL_call c pass pass
######################################################################
# QUESTIONS
######################################################################
1. Why isnt app #2 picking up the cache? I think maybe the rails app returns a slighly
different header that could be causing a problem but Im not sure what in the header would
cause problems according to the varnishlog output :(.
2. Is there a way to check what is in the cache from the "telnet localhost 6082" or anything
else, if I have the key, "/articles;feed?tag_id=16" in this case. Maybe thats whats going on,
the data isnt being written into the cache...
3. I also tried adding some C code (commented out) to maybe puts some output out or writing to
a file (maybe through a system call could work too) to see which part of the vcl chain Im
hitting. Whats a good way of doing that? This would be great to know how to do so I can
check the vcl rules.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment