Changeset 1506

Show
Ignore:
Timestamp:
10/06/07 10:49:43 (3 years ago)
Author:
phk
Message:

Take a shot at light-weight "Vary:" processing.

When we cache an object with a "Vary:" header, we generate
a "vary matching string" which can be used to efficiently
check for compliance when doing a cache lookup.

Only very lightly tested (ie: cnn.com).

For a full description of the reasoning, please see

 http://varnish.projects.linpro.no/wiki/ArchitectureVary

Location:
trunk/varnish-cache/bin/varnishd
Files:
1 added
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/varnish-cache/bin/varnishd/Makefile.am

    r1504 r1506  
    2626        cache_session.c \ 
    2727        cache_synthetic.c \ 
     28        cache_vary.c \ 
    2829        cache_vcl.c \ 
    2930        cache_vrt.c \ 
  • trunk/varnish-cache/bin/varnishd/cache.h

    r1503 r1506  
    225225        unsigned                xid; 
    226226        struct objhead          *objhead; 
     227 
     228        unsigned char           *vary; 
    227229 
    228230        unsigned                heap_idx; 
     
    463465/* cache_synthetic.c */ 
    464466void SYN_ErrorPage(struct sess *sp, int status, const char *reason, int ttl); 
     467 
     468/* cache_vary.c */ 
     469void VRY_Create(struct sess *sp); 
     470int VRY_Match(struct sess *sp, unsigned char *vary); 
    465471 
    466472/* cache_vcl.c */ 
  • trunk/varnish-cache/bin/varnishd/cache_center.c

    r1503 r1506  
    299299        sp->obj->cacheable = 1; 
    300300        if (sp->obj->objhead != NULL) { 
     301                VRY_Create(sp); 
    301302                HSH_Ref(sp->obj); /* get another, STP_DELIVER will deref */ 
    302303                HSH_Unbusy(sp->obj); 
  • trunk/varnish-cache/bin/varnishd/cache_hash.c

    r1503 r1506  
    149149                } 
    150150        were_back: 
    151                 /* XXX: check Vary: */ 
    152151                if (!o->cacheable) { 
    153152                        /* ignore */ 
     
    160159                        VSL(SLT_ExpBan, 0, "%u was banned", o->xid); 
    161160                        EXP_TTLchange(o); 
    162                 } else 
     161                } else if (VRY_Match(sp, o->vary)) 
    163162                        break; 
    164163                o->refcnt--; 
     
    255254                free(o->http.ws->s); 
    256255 
     256        if (o->vary != NULL) 
     257                free(o->vary); 
     258 
    257259        HSH_Freestore(o); 
    258260        free(o);