Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi there,
Could anyone recommend an approach to warm the cache for auth cache roles. Seeing as each role has a separate cache, how should this be done…? Any help would be appreciated.
John
Comments
Comment #1
johnald CreditAttribution: johnald commentedWhat I would also like to ask is whether it is possible to add data to the specific authcache through php. More specifically through a webcrawler... like as suggested here: https://drupal.org/node/1681700
What function (either built-in or from authcache module) would allow me to do this.
Comment #2
znerol CreditAttribution: znerol commentedPlease take a look at the Cache Warmer drush extension. It supports crawling with authenticated users.
The most prominent problem I see at the moment is that authcache will not save a page to the cache if the
has_js
cookie is not on the request. However it is possible to simply pretend that the cookie is there by directly manipulating the$_COOKIE
superglobal, e.g. insettings.php
(see also #2092185: no_cache_reason: "Caching disabled for session (nocache cookie set)"):Comment #3
jason.fisher CreditAttribution: jason.fisher commentedWith that has_js tip, I am successfully using HTTPRL Spider now to crawl as a masqueraded user. It is not necessarily secure (currently relying only on ip_address() matching 127.0.0.1), but it works.
https://drupal.org/node/2172933
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedI put together a couple of shell scripts that use wget & an XML sitemap created by the XML Sitemap module to crawl & cache Authcache pages for both anonymous & authenticated users. I have an account I created (named 'authentic') specifically to work with the authenticated user script. I run them daily from cron. This site only uses https, so to get authenticated page cache for http you would need to also hit those pages from http. In addition, if you have multiple combinations of user roles, you will need to do this for each combination to get pages cached for them (this is the way Authcache prefixes cached pages with a unique id for each combination of roles).
For anonymous users:
For authenticated users:
I hope this will help somebody. Perhaps a script like this can be incorporated into Authcache?
Comment #5
NWOM CreditAttribution: NWOM commentedHTTPRL Spider in combination with XMLRPC Page Load allows you to crawl all entities on a site with any user ID of your choosing. You can also define non-entity paths to crawl, as discussed here: #2684849: Crawl Pages with specific Views Exposed Filters active
I also added a feature request to potentially allow dynamic caching based on site usage here: #2684945: Provide Cache Miss View (Uncached Pages)
Comment #6
NWOM CreditAttribution: NWOM commentedSetting to Active, since no patch is attached.
Comment #7
vadym.kononenko CreditAttribution: vadym.kononenko commentedI see 'XMLRPC Page Load' can not warm cache as 'xmlrpc' uses POST only method and authcache exludes such method from caching.
See: xmlrpc() -> _xmlrpc()
See: authcache_authcache_request_exclude()
See: authcache_builtin_cacheinc_retrieve_cache_page()
Comment #8
firewaller CreditAttribution: firewaller commentedThis module Force JS does what #2 suggests and works for me when using Cache Warmer.
Comment #9
firewaller CreditAttribution: firewaller commentedOne caveat with using the Cache Warmer module (and any other drush-based cache warming systems) is that Authcache skips active cache backends for drush commands. When using authcache_debug, after I run the cache-warmer drush command I get in the authcache_debug dblog: "Excluded: No active cache backend."
Upon looking for the above error in Authcache, I see that the reason there is no active cache backend is due to the module ignoring drush entirely:
It makes sense that Authcache is not initialized during normal drush commands, but is is possible to implement a bypass specifically for cache warming drush commands?
Comment #10
firewaller CreditAttribution: firewaller commentedComment #11
znerol CreditAttribution: znerol commentedNo activity, closing this.