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

vinmassaro’s picture

I see the same Authcache Debug message if I disable Authcache Ajax and instead use Authcache ESI as a client.

znerol’s picture

I did not test combinations of ESI and Ajax until now.

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"

Are you sure that the has_js cookie comes through to the backend?

it returns the username of the user who requested the original page that was stored into Varnish cache.

Try to exclude '/ajaxblocks' from caching in Administration » Configuration » System » Authcache » Page Caching Settings.

znerol’s picture

I see the same Authcache Debug message if I disable Authcache Ajax and instead use Authcache ESI as a client.

If 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.

vinmassaro’s picture

Hmm, 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.

znerol’s picture

The correct configuration is:

$conf['reverse_proxy'] = TRUE;
$conf['reverse_proxy_addresses'] = array('ip-of-your-varnish-instance-here');
znerol’s picture

Status: Active » Postponed (maintainer needs more info)

I 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.

znerol’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Closed (outdated)