I'm not able to get Ajax working for blocks with Authcache Varnish. Pages are being returned from Varnish correctly when I don't have any Authcache-enabled blocks. The block in question outputs the logged in user's username. Here is what I've tried:
Authcache Ajax
1. Enable Authcache Block, Authcache Ajax
2. Edit block
3. Set Authcache settings:
- Cache lifetime: 1 hour
- Check 'Per User'
- Clients: check 'Ajax'
- Fallback: 'Cancel caching'
Outcome
Caching is cancelled when I test a page that should be delivered from Varnish. Authcache Debug reason says "No client for fragment block-u-q-3600"
Ajax Blocks module
1. Disable Authcache Block, Authcache Ajax
2. Edit block
3. Set Ajaxblocks settings:
- Load block via ajax: Yes
- Load the block on cached pages for these roles only: Staff, Student, Faculty
- Load the block on uncached pages for these roles only: Staff, Student, Faculty
Outcome
Cached page is delivered from Varnish, and the block appears to be loaded by Ajaxblocks (I can see a GET request for /ajaxblocks?blocks=block-2&path=node/13&nocache=1&_=1380559006956 in Live HTTP headers), but it returns the username of the user who requested the original page that was stored into Varnish cache.
Comments
Comment #1
vinmassaro CreditAttribution: vinmassaro commentedI see the same Authcache Debug message if I disable Authcache Ajax and instead use Authcache ESI as a client.
Comment #2
znerol CreditAttribution: znerol commentedI did not test combinations of ESI and Ajax until now.
Are you sure that the
has_js
cookie comes through to the backend?Try to exclude '/ajaxblocks' from caching in Administration » Configuration » System » Authcache » Page Caching Settings.
Comment #3
znerol CreditAttribution: znerol commentedIf you are working with the latest code, please be sure to setup
$conf['reverse_proxy']
and$conf['reverse_proxy_addresses']
in your settings.php. Authcache Varnish now validates whether the request came in through a configured proxy. If this is too much hassle, set$conf['authcache_varnish_validate_reverse_proxy_address'] = FALSE
in order to skip this check.Comment #4
vinmassaro CreditAttribution: vinmassaro commentedHmm, I need to pull in the latest dev version and update from example.vcl to make sure things are
When I quickly tried to update my VCL and set
$reverse_proxy_addresses = array('127.0.0.1');
, I get a redirect loop error when trying to log into the site with CAS :( This happens also with the included example.vcl as well. I don't see this happen if I log into other sites without Authcache enabled (but also passing through the same VCL), so I don't believe it's from the VCL changes.Comment #5
znerol CreditAttribution: znerol commentedThe correct configuration is:
Comment #6
znerol CreditAttribution: znerol commentedI cannot reproduce your original problem. With the current VCL, Authcache Blocks are delivered properly regardless of whether they are pulled in using Ajax or ESI.
Comment #7
znerol CreditAttribution: znerol commented