I'm trying to learn how to set up Panels caching. I watched a video on mastering Drupal caching and I have the book by Earl Miles on Panels and Views, Drupal's Building Blocks, but unfortunately there's not a chapter specifically on caching.

So, I have a panel that overrides the user profile, and on this panel I have a variant that has a number of views content panes. I would like to cache these content panes per user profile displayed, since obviously they should be different for each user who is viewed.

Each of these content panes has a Contextual filter on Content: Author UID.

The value is supplied to Panels by the Argument input option in Views, for which the Content: Author uid source is set to From context and Required context is set to User ID:

views screenshot

In Panels, on the Simple cache configuration screen, for the Granularity, I can choose Argument or Context, and the help text is this:

If "arguments" are selected, this content will be cached per individual argument to the entire display; if "contexts" are selected, this content will be cached per unique context in the pane or display; if "neither" there will be only one cache for this pane.

But in Views, the option is called argument input and the value I chose was from context. So am I dealing with an argument or a context?

If possible, both a general answer describing the difference between argument and context in this case and a specific answer to my question would be fantastic.

  • Posted an answer, hopefully it answers both the generic question and your situation, but let me know if I didn't.
    – Letharion
    Aug 23, 2013 at 17:06

1 Answer 1


Disclaimer: I usually find that the setup is simple enough that the distinction isn't necessary, thus I must admit my practical experience is limited, and I could be wrong below.

Arguments, are based on the URL. node/5 gets cached separately from node/7, because 5 is different from 7. node/5/7, if you where to have such a path, is yet another cache.

Contexts, are generally derived from Arguments, and in the examples above, it's very likely that the caches would be exactly the same, regardless of which cache option one would pick. However, Contexts, can also come from (at least) three other sources, Relationships, manually defined ones, and the special case, the logged in user.

If your context is both a node from the URL, and a user pulled from an entity reference on the node, then your context has two unique entities, or two contexts, but only one argument.

So one chooses Context or Argument depending on whether you want the cache to take any "extra" contexts into question, or not.

But in Views, the option is called argument input and the value I chose was from context. So am I dealing with an argument or a context?

Unfortunately the terminology isn't exactly the same between the two modules. Panels calls dynamic pieces of the URL arguments, and it creates contexts from those. Views, means something closer to a function argument, when it refers to arguments, and in this particular case, it will derive the argument from a context, passed in by Panels.

  • So, say, if I want the cache to take into account both the logged in user and the user being viewed, I should use Contexts not Arguments? Aug 23, 2013 at 17:21
  • 1
    Yes, if you use Arguments in that situation, logged in user would be ignored.
    – Letharion
    Aug 23, 2013 at 17:25
  • I added that to the list of context sources.
    – Letharion
    Aug 23, 2013 at 17:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.