Found this link useful for cache discussion

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
Anonymous's picture

I found this discussion useful while exploring cache and cron issues for my site, real Life English.

http://tomroelandts.com/articles/how-to-ensure-that-visitors-always-see-...

Comments

Warming a cache is an idea

Garrett Albright's picture

Warming a cache is an idea not without merit, but I don't understand why the author thinks it's necessary to clear the cache before doing so - or especially why they're clearing cache after a cron run, which AFAIK nukes the cache anyway.

At any rate, I don't think it's a huge crime for most sites to serve a visitor an uncached page the first time after a cache clear. Cache warming like this might actually cause more slowdown on a smaller site, since it's going to be spending a lot of time generating all the site's pages all at once, instead of spreading that out over time as visitors hit the site - and for less popular pages, there's a chance a visitor won't hit that page between cache clears at all, so the cache item for it was generated for nothing.

Also, Drush works just fine on most shared hosts I've tried it on, though installing it can be a bit unintuitive.

Keep the cache warm, don't cool it

nestor.mata's picture

I agree with Garret.

Cache warming is actually an overhead to the server, is like getting a huge traffic at a moment.
There is no need to cause high traffic effects on your site and server without need.

Cache warming in my opinion makes sense after a new deployment, after a new change, so you can make sure most pages are cache before the first users arrive and is just a one time thing after a change.
But scheduled cache warming will have more cons than pros.

Answering Garret's question, yes and no, some cache's may get cleaned after a cron, some may not, all depends on your specific cache's configuration. You may have pages cached for 3 hours although you may run the cron every hour for example, but, that is indeed what you want if you configured that way, so that would be the desired effect, contrary to clearing all caches on every cron run just to re generate them while they will show no change (what is the point?)

So, bottom line, my advice is, keep the warm cache command near to you, and use it when you just pushed a new change or added important new content or so, in that way you can make sure you clear old content and warm the cache, but don't get it cold, let it keep warm by not clearing it on every cron run.

~Nestor

why clear cache first?

trainingcity's picture

I was also perplexed by the clear cache command in the script, it seems unnecessary?

No question on the performance hit as the cache is (re)generated.

I think the broader question is this, it is very, very difficult to find a through explanation of DBP (Drupal Best Practices) when it comes to caching and logged in site users. Between views caching, drupal caching, APC, etc, it is extremely confusing to know how to even approach a cache strategy.

BTW, what is the impact of running this script on a site with apc operating?

As for natural cache warming, it is difficult in a low volume site as relatively few site visitors per hour means relatively few opportunities to build the cache.

Specific cases

nestor.mata's picture

There is no one size fits all solution, that is why may be confusing.
You do need to know and understand your options, but more important understand your site and your users usage of your site.

Things to consider:
- Are your users anonymous, logged in or a mixture? Anonymous users are a lot easier, you could just cache everything.
- How often changes your content and how impact the changes, is just a block or the complete content that changes.
- Then you need to understand each part of your site and analyze each of them.

General things:
- Drupal search is OK, but if you have lots of content or your site usage is based by a lot of searching you should consider a real search engine like Solr or Sphinx.
- CSS and JS should be optimized and minified, Drupal does this in core, but there are modules for advanced and better ways of doing it.
- Complete page caching is great when the site usage allows this. Bootstrap is great for caching complete pages for anonymous users
- Where you need to cache logged in users you could move to AuthCache, but you will need to get your hands dirty to customize for your specific site.
- Op Code optimizer, you should use one, no reason not to, the code ops "compile" and cache php code so it is faster to process next time
- Key/Value caches, you definitely should use Redit, Memcache or any of those to replace some of Drupal's caches, you should understand which cache you should improve, key/value is mostly great, but not for every situation
- Reverse proxy, you can use things like Varnish as a middle man that focus on caching, this well configured is a great boost, but you should understand what needs to be improved and how, for example you could force greater time cache for images and static content, but to avoid caching dynamic images that your application generates
- Improve MySQL indexes and configuration to make sure it doesn't do much I/O work and works mostly on memory, but then, all depends on your server resources too.
- Expiration headers, you can configure Apache to set expiration times on the files, like images or CSS/JS, that way to tell the client's browser to cache the files locally and don't ask them again for a while

This is just an example of ways to improve your site, but all depends on your resource, users' use case and the site it self

configuring memecached and authcache

trainingcity's picture

I decided to explore authcache configuration today and to try out memcache. For anyone interested, here is a link explaining how to setup memecache:

Drupal details:

https://drupal.org/node/1131468

In centos:

http://tag1consulting.com/blog/memcache-centos-fedora

Authcache removed

trainingcity's picture

I could not get authcache configured properly for my site yesterday. I may try it again, but I was experiencing error messages for all standard node pages, my panels & views seems to work fine.

In any case, I decided to try memcache as authcache wanted a backend and I had meaning meaning to try it. So far so good, I think I am getting a performance boost but time will tell. I increased the memcache memory allocation in the php.ini file to 384 MB.

Question for the group. I am already running apc, what are the issues in running "both" apc and memcache? There are lots of discussions out on the web on this issue, but another one can't hurt!

http://stackoverflow.com/questions/815041/memcached-vs-apc-which-one-sho...

Authcache is in beta at the

znerol's picture

Authcache is in beta at the moment. I'm keen to iron out any issues before going stable. Therefore if you still have the error message handy, please submit it as a bug report.

bug report

trainingcity's picture

@znerol Will do. I was a bit lazy yesterday and didn't bother tracking down the error. I was getting a blank page with just the there has been an error message every time I visited a /node regardless of content type.

I was able to display all of my panels and views pages.

Disabling authcache solved the problem.

Memcache seems to having a dramatic effect on site performance

trainingcity's picture

Testing the site today I am seeing what appears to be a dramatic improvement in performance as various authenticated user accessed db heavy pages (panels with multiple views, etc) are warmed in memcache. I am very surprised as I wasn't expecting this level of performance improvement.

Great summary nestor.mata

trainingcity's picture

@ nestor.mata That is a great summary of caching considerations you provided above, thanks!

Article on configuring memcache & question on conf

trainingcity's picture

Found this article on memcache configuration with Drupal 7 and thought it might be of interest to someone:

http://andrewdunkle.com/how-install-memcached-drupal-7

Also, meant to say that I defined the memcache memory allocation here, not in php.ini:

/etc/sysconfig/memcached

Note that the location and possibly the name of the conf file may change with your OS.