I am not 100% sure if this is the best area to ask.... but I was just curious if anyone has attempted or successfully setup domain access with the varnish caching system?

I searched around Drupal.org as well as across the web, but I could not find any topics on this particular issue. I realize that there are discussions on caching in general as well as possible issues with the Boost module when used with Domain Access. But I was not sure how much they applied to Varnish in particular.

I am still quite new to this form of caching system, so any assistance or direction would be greatly appreciated. I just figured that I would ask first before I spend a great deal of time and energy going in the completely wrong direction.

Thanks in advance everybody.....

Comments

davidsilverthorn’s picture

I'm using Varnish with my server. To my knowledge it is working fine. Varnish takes the URL into consideration when it caches, so it should be seeing different URL's and caching correctly.

If anyone has anything to say to the contrary, I'd like to know though. I'm pretty new to Varnish myself

EDIT: Thought this was Drupal 7.x branch at first (this happens when you only use Drupal 7 now days). Though Domain Access won't have issues with Varnish from my experience, only Drupal 7.x is fully compatible with Varnish. Drupal 6.x is NOT, however, compatible with Varnish without a module or using Pressflow (a drop-in replacement to Drupal 6.x). I highly recommend Pressflow to people who are using Drupal 6, as it nearly has 100% compatibility with Drupal 6 modules, with a few added enhancements, including what is needed to be compatible with Varnish. Also, I can attest that Domain Access works with Pressflow, just for the skeptics :-).

ydnar79’s picture

Thanks david,

I was wondering if that would be the case after reading more on how varnish works.

One other quick thing, do you have any issues with content showing up on sites that it is not supposed to be accessed from? For example, content that is only viewable on site A can also be seen on site B because of the caching... If I remember correctly, that was an issue that I seen others having with Boost.

However, I guess if Varnish is purely going by the URL, this would probably NOT be the case. But I was just curious.

And thanks again for the quick reply. As I said before, this is uncharted territory for me and any assistance is greatly appreciated!

agentrickard’s picture

Nice to know that Varnish works. My recent tests with Boost indicates that module also handles DA properly.

In general, as long as an absolute URL is used as the cache id, then it works fine. This is how core {cache_page} works.

davidsilverthorn’s picture

Actually, when I log in I see every piece of content I've written no matter which site I am on. So, yes, I see content from site A and B in both sites. However, I have found that anonymous users see the content correctly. Whether or not this throws off Varnish has yet to be seen. I would imagine that Varnish may take cookies or something in account so that it won't cache pages from logged in users. I feel like I read something like that...it's been a while since I researched Varnish though.

Also, are you using Pressflow or the Varnish module with Drupal 6? I just noticed that this thread was under the Drupal 6.x branch. Drupal 6.x doesn't actually support Varnish's method of caching. but Pressflow is a drop in replacement (it's an enhanced Drupal 6 that it's nearly 100% compatible with Drupal 6 modules). Just making sure, because I know I'd be beating myself up if I implemented it and found out later that it never worked. It was actually Pressflow that got me into Varnish. I highly recommend it if your sticking with Drupal 6. Drupal 7 is compatible with Varnish btw.

agentrickard’s picture

@davidsilverthorn see #1022220: All sitewide content being displayed for logged in editors for the answer to that question. If you are user 1 or can bypass node access, the rules are not applied to you.

agentrickard’s picture

Status: Active » Closed (works as designed)
burningdog’s picture

Status: Closed (works as designed) » Active

This is good news! I'm about to start some testing of DA with varnish, and the drupal performance page says that DA is "incompatible with external-mode caching". That's because it implements hook_boot, which looks like:

/**
 * Module setup tasks.
 *
 * 1. Adds the domain user data to the $user object.
 * 2. Ensures that our custom_url_rewrite_outbound() is loaded.
 *
 * @link http://drupal.org/node/529026
 * @link http://drupal.org/node/820062
 */
function domain_boot() {
  global $user;
  // Load domain information to the $user object.
  $user->domain_user = domain_get_user_domains($user);
  // Properly load custom_url_rewrite_outbound().
  include_once('settings_custom_url.inc');
}

(I read through both of the d.o links mentioned to get a better idea of why the code in domain_boot() is there).

If I'm not assigning a domain to users (i.e. I set DOMAIN_ASSIGN_USERS to FALSE on installation) then I don't need to load domain information to the $user object. Besides, external caching only works for anonymous users, so when users are logged in then domain information would be loaded into $user anyway.

Which brings us to settings_custom_url.inc - the only bit that I can see that's relevant there to be called on hook_boot() is

/**
 * Implement custom_url_rewrite_outbound() if the url_alter.module is not enabled.
 */
if (!function_exists('custom_url_rewrite_outbound')) {
  function custom_url_rewrite_outbound(&$path, &$options, $original_path) {
    domain_url_outbound_alter($path, $options, $original_path);
  }
}

According to http://drupal.org/node/820062 custom_url_rewrite_outbound() needs to be in hook_boot() so as to not have to set the weight of DA higher than any other module which does custom url rewriting (I think previously the DA include code was in hook_init() which meant in some cases it would be loaded later and lead to undesired results - i.e. some urls not being rewritten properly to their source domains).

If I'm not using url_alter.module on my site, then surely I don't need this function to load on hook_boot() - hook_init() would be fine? I can't figure out why enabling external-mode caching would break Domain Access in this case?

The INSTALL.txt file says, in section 4.4.3, that I can directly include settings_custom_url.inc in settings.php - if I did that, then can I safely ignore the external-mode caching warning on the performance page?

Marking as "active" because I'm doing some in-depth testing and will report back as I find things.

roborn’s picture

subscribing

agentrickard’s picture

The current functionality of the url rewrite was put in by the URL Alter maintainer. The user load is a convenience method since user_load() is a untrustworthy.

agentrickard’s picture

I would think you will be fine, since neither of these functions affects the output of cached pages. The use of hook_boot() triggers a generic warning that I think you can safely ignore.

burningdog’s picture

Thanks agentrickard - good to know re: hook_boot()

agentrickard’s picture

Status: Active » Closed (works as designed)
mvc’s picture