Tuesday, June 29, 2010

Books for ‘Advanced’ Programmers

Do advanced programmers read books?

There is a stage where you are no longer a 'beginner', yet you still want to learn things (Actionscript is on my list, currently). I've been looking for books which do not start from the 'How to install' or 'How to configure IDE for that' phase, but which assume the reader has more knowledge and has reached a 'can-do-it-yourself' level.

Do you have any good book recommendations?

books programmer
flag edited Feb 18 '09 at 17:19
lillq
2,01731532 asked Dec 26 '08 at 4:01
Vardhan Varma
887412

2
Wouldn't this do better as a community wiki, one book per answer? – David Thornley Sep 16 '09 at 20:15

closed as subjective and argumentative by Mehrdad Afshari, Bart K., dmckee, jitter, sth Jan 30 at 15:28
It's impossible to objectively answer this question; questions of this type are too open ended and usually lead to confrontation and argument.
25 Answersoldest newest votes 28
My answer would depend on how you define "advanced". Some of my professional colleagues use that term to indicate an increasing degree of specialization, while others use it to indicate mastery of a broader set of skills and perspectives. If you mean the first, I can't answer without knowing the area(s) of interest. (So I'll assume you mean the second, and forge ahead. ;-)

In no particular order, I'd recommend:

Effective Java, second edition, Joshua Bloch, 0-321-35668-3 : This is the only language-specific book on my list, but a careful (advanced) reader will also gain insights which apply to other languages.

Test Driven, Lasse Koskela, 1932394850 : Although the examples are in Java (he had to pick some language), the principles apply to a wide range of languages, and are carefully explained.

Refactoring to Patterns, Joshua Kerievsky, 0-321-21335-1 : Tying together two of the most important concepts in recent OO development, this book richly illustrates the process of continuous improvement of code.

Working Effectively with Legacy Code, Michael C. Feathers, 0-13-117705-2 : Written for the majority of us (those who don't get to spend all their time creating beautiful new ivory towers, but have to maintain and evolve existing systems without breaking them), this book has a wealth of techniques for making code more manageable, reliable, and work-with-able. Examples are given in Java, C++, C, and C#.

Test-Driven Development: A Practical Guide, David Astels, 0-13-101649-0 : Covers refactoring, programming by intention, mock objects, and other techniques, including frameworks for C++, C#, Python, VB6, Ruby, Java, and Smalltalk.

Refactoring: Improving the Design of Existing Code, Martin Fowler, 0-201-48567-2 : The classic book on taking poorly designed code and making it better without breaking it.

Prefactoring: Extreme Abstraction, Extreme Separation, Extreme Readability, Ken Pugh, 0-596-00874-0 : No, the title is not a typo! The author focuses on taking what we learn from maintenance of existing code as a basis for doing better design the next time around. The guidelines and principles are illustrated in detail with sample code.

Beautiful Code: Leading Programmers Explain How They Think, Andy Oram & Greg Wilson, eds., 0-596-51004-7 : A thought-provoking set of essays from a wide range of experts and accomplished practitioners.

The Best Software Writing: I, Joel Spolsky, ed., 1-59059-500-9 : Another collection of essays that will make you think, framed in Spolsky's characteristic style (meaning that you'll either love it or hate it! ;-).

Purely Functional Data Structures, Chris Okasaki, 0-521-66350-4 : Reading this book almost amounts to a graduate-level class in how to solve really hard programming challenges in an elegant style.

How to Measure Anything: Finding the Value of Intangibles in Business, Douglas W. Hubbard, 978-0-470-11012-6 : Yeah, we all hate estimating. Get over it. Whether estimating running characteristics of a program, development time, or ROI of a new piece of code, it's not as hard as we all think it is. This book turns your head sideways for a better perspective on the classic back-of-the-envelope.

YMMV, but I found all of these books worthwhile additions to my (already bulging) bookshelf.
link|flag edited Dec 26 '08 at 17:41

answered Dec 26 '08 at 15:04
joel.neely
8,14111437

I agree. When you understand the topics in Effective java you could judge better some other languages and apply the lessons there. – Support - multilanguage SO Dec 26 '08 at 22:23
I'm surprised that Code Complete hasn't made it to that list – Maciek Sep 16 '09 at 20:11




25
If you're advanced enough there comes a point where "How To" books are no longer interesting because they are either monotonous and assume no programming background or unnecessary because they teach you things you could teach yourself with a decent web browser and a days worth of googling. So why not try some theory? Here's what I've enjoyed:

Algorithms by Dasgupta, Papadimitriou and Vazirani - A good introduction to algorithms and algorithmic analysis. It will help you analyze your own work, show you timeless optimization techniques that aren't necessarily obvious and give you a solid foundation for choosing algorithms for your own work.

Discrete Mathematics and Its Applications by Kenneth Rosen - An introduction to the mathematics behind most of computer science.

The Pragmatic Programmer by Andy Hunt and Dave Thomas - How to do your job as a programmer well.

Refactoring: Improving The Design of Existing Code by Fowler, Beck, Opdyke and Roberts - What to do with the code you've written before you finished this book.

And these are just scratching the surface, there's plenty out there for the more advanced programmer.

EDIT: You can find a pre-release version of the first book, Algorithms, released by the authors for free here.
link|flag edited Dec 26 '08 at 22:07

answered Dec 26 '08 at 4:16
Eric Scrivner
786413

Refactoring and TPP both had a big impact on my as a programmer. I'll put the others on my list. – Jay Bazuzi Dec 26 '08 at 18:01

9
To the extent that I'm an advanced programmer (other than in age, that is), I read books. I doubt if I'm alone in doing so. Indeed, IMO, any serious programmer is continually learning, and much of that learning will come through reading books.

However, as Eric Scrivner says (and, indeed, as the questioner says), as you become a more experienced programmer, the books you read are different. Books that would be impossibly dense for someone still learning a language (for example, Harbison and Steele's "C: A Reference Manual") become useful as a reference. It would be tough to learn the language from the book; it is an excellent source of detailed information, though. If (when) you become a beginner again (learning a new language, for example), you may need to fall back onto books more nearly suited for beginners. However, you can often cope with more advanced books than those that someone who is not only learning a particular language but also learning how to program at all could cope with.

Many of the interesting books are extremely specialized. For example, "Calendrical Calculations, 3rd Edn" by Dershowitz and Reingold is an incredibly useful book - if you happen to be dealing with calendars. If you have no interest in or need of handling multiple calendar systems, the book is of zero use to you. Another book in a similar vein is "Concurrency Control and Recovery in Database Systems" by Bernstein, Hadzilacos and Goodman; another is "Time Granularities in Databases, Data Mining and Temporal Reasoning" by Bettini, Jajodia and Wang. Very useful if that's what you need; useless (except for insomniacs) if you don't need them.

However, there are a lot of books that are only tangentially about a specific programming language or system, but that help you program better. Others have mentioned "The Pragmatic Programmer", for instance, and "Clean Code" has been cited while I'm typing.

I'd add some more to the list:

Knuth "Literate Programming"
Myers "The Art of Software Testing, 1st Edn" ("2nd Edn" - more expensive).
Hoffman and Weiss "Software Fundamentals" (collected and annotated papers of David Parnas - very interesting)
Raymond "The Art of UNIX Programming"
Kernighan and Pike "The Practice of Programming"
Feathers "Working Effectively with Legacy Code"
Beck "Test Driven Development"
These all, in different ways, take you beyond the basics in a largely language-agnostic way (and largely platform-agnostic too - though there's a strong Unix/Linux bias in my preferences and therefore reading materials).
link|flag edited Dec 30 '08 at 6:10

answered Dec 26 '08 at 5:32
Jonathan Leffler
53k23494



7
Many of the books suggested I would tag as more for the intermediate programmer. Some good old intermediate-level books not already mentioned:

Programming Pearls by Jon Bentley
The Unix Programming Environment by Kernighan and Pike
Software Tools in Pascal by Kernighan and Plauger
And a couple of "advanced" titles:

Essays in Computing Science by C. A. R. Hoare (actually a mix of material at all levels)
A Discipline of Programming by Edsger Dijkstra (for the hard-core formalist)
link|flag answered Dec 26 '08 at 7:26
Norman Ramsey
53.8k356151

I would add that these are for readers who don't want to be treated like babies who must be warned away from techniques considered "evil" by self-appointed prognosticators. – Mike Dunlavey Dec 26 '08 at 18:22

6
The Art of Computer Programming by Knuth.

Introduction to Algorithms by Cormen, Lieserson, Rivest and Stein.
link|flag edited Dec 26 '08 at 13:24

answered Dec 26 '08 at 4:08
S.Lott
87k479209

It's a great book, but only really useful if you want to pursue the analysis of algorithms. – Mitch Wheat Dec 26 '08 at 5:41
@Mitch Wheat. Disagree. It is foundational stuff -- with an advanced presentation. Algorithm design and analysis is the core programming skill. After that come all the various languages and tools for implementation. – S.Lott Dec 26 '08 at 11:55
I wouldn't say algorithmic design is the core programming skill in itself. You'd be missing machine organization and hardware architecture. The two go hand in hand. Today everyone things its all about algorithms due to managed languages, and nobody learns the machine any more. – ApplePieIsGood Dec 26 '08 at 14:54
@ApplePielsGood: Disagree. Machine architectures change. Managed code (and related oS features) comes and goes. Algorithm design is the one invariant skill over the architectural considerations of the harware currently popular. – S.Lott Dec 26 '08 at 18:38

6
Feynman Lectures on Computation

The C++ Programming Language by Stroustrup

Compilers (the Dragon Book) by Aho, Sethi, Ullman

Lex & Yacc by Levin, Mason, Brown

These are my favorite advanced programming books. They are sorted by inverse specificity.
link|flag edited Dec 26 '08 at 14:32
Steven A. Lowe
28.4k247112 answered Dec 26 '08 at 5:10
Colin
2,151621



6
There are some books out there that's more abstract, but it should be part of your bookshelf.

The Mythical Man Month
Code Complete 2
Peopleware: Productive Projects and Teams
Pragmatic Programmer: From Journeyman to Master
And for more technical, generic stuff:

Design Pattern
Structure and Interpretation of Computer Programs
Introduction to Algorithms
Programming Pearls
We never stop learning. When we do, we're dead.
link|flag answered Jan 22 '09 at 1:59
KOkon
26717

Seconded! Especially if "advanced" means "higher" position ;) – Heartless Angel Jan 22 '09 at 5:16
+1 for the first set, these are great books to add to the collection. – Paolo Jan 29 at 20:20

4
Lisp in Small Pieces by Quinniec

The Art of the MetaObject Protocol
link|flag answered Dec 26 '08 at 4:05
Technical Bard
740313



4
Pragmatic Thinking and Learning will help you narrow the gap to reach rockstar-dom ;)

And Code Complete. contains basic to advanced stuff, a good reference to keep at your desk.

Plus Understanding the Linux Kernel - if you're really hardcore.
link|flag edited Dec 26 '08 at 7:33
Jonathan Leffler
53k23494 answered Dec 26 '08 at 5:34
melaos
2,132718



4
Design Patterns by Gamma, Helm, Johnson, Vlissides. (good advanced object-oriented techniques)
Algorithms by Cormen, Leiserson, Rivest, Stein. Covers most of the common data structures and algorithms, and big-O notation & all that.
Numerical Recipes by Press, Teukolsky, Vetterling, Flannery. Good for numerical algorithms (approximating functions, solving roots of equations, numerical integration, etc.) -- not something you normally need to deal with, but if you do then this is a good place to start.
Structure and Interpretation of Computer Programs by Abelson and Sussman. It's also available online. This uses the Scheme language (similar to LISP but simpler) to discuss algorithms from a more abstract approach than found in most books. It gives some interesting perspectives, though, that you won't find many other places.
link|flag edited Dec 26 '08 at 15:22

answered Dec 26 '08 at 13:21
Jason S
15.9k21458



3
If you are an enterprise programmer, take a flip through Martin Fowler's Patterns of Enterprise Application Architecture .

Its not light reading unfortunately (unlike pragmatic programmer mentioned above), but it does have some goodies in there. Though most enterprise frameworks these days basically does what that book says anyway (ala hibernate, spring, etc in java world).

Another one that was recommended to me (but I havent had time to read yet) is Java Concurrency in Practice. Its apparently the book for concurrent programming advice.
link|flag answered Dec 26 '08 at 4:44
Chii
3,892413



3
Effective Java

Clean Code
link|flag answered Dec 26 '08 at 4:47
Kire Haglin
1,44416



3
This is not great answer to your question but just wanted to point out I think it's a good idea to read books like http://www.mindhacks.com/book/ instead of focusing only technical books. Books about "concentration", "reading faster", "learning methodologies" and "problem solving".
link|flag answered Dec 26 '08 at 14:46
dr. evil
5,02011144



2
I'd recommend the Wrox Professional books which presume a level of prior experience.
link|flag answered Dec 26 '08 at 8:38
Dean Madden
6816



2
I would like to throw in McConnell's Code Complete to the mix (one of my absolute favorites). Also see Scott Hanselman's book list.
link|flag answered Dec 26 '08 at 18:11
Echiban
1128



1
This one is not a book, but I'd say it's a big high-quality collection of computer related knowledge.

http://c2.com/cgi/wiki?WikiList
link|flag answered Dec 26 '08 at 17:56
Anonymous




1
The Definitive ANTLR Reference

Every advanced-level developer should be able to write language parsers.
link|flag answered Dec 26 '08 at 18:40
RogerV
1,014313



1
I strongly suggest "The Algorithm Design Manual" by Steven S. Skiena. It's a great read that covers a wide variety of algorithms and contains many helpful examples.
link|flag answered Dec 31 '08 at 2:22
Nick Gerakines
741112



1
"The Design and Evolution of C++" is a great thing to read (good even if you do not know C++ well).

I also second "SQL for Smarties".
link|flag answered Dec 31 '08 at 3:07
Kendall Helmstetter Gelner
14.4k11532



1
Any of Marvin Minsky's books:

Computation, Finite and Infinite Machines

Semantic Information Processing

Society of Mind

Perceptrons
link|flag edited Dec 31 '08 at 3:57
Jonathan Leffler
53k23494 answered Dec 26 '08 at 18:32
Mike Dunlavey
9,43111330



0
Paradoxically, after approaching some level of proficiency in programming I found myself learning much more from math books than programming ones.

What I believe is a crucial skill for every programmer is ability to easily handle a lot of abstractions and strip them easily into simpler concepts. Nothing beats math in this.
link|flag answered Dec 26 '08 at 18:40
maurycy
29316



0
In addition to the others:

Beautiful Code
List item
Unix Power Tools
SQL For Smarties
Practice of Programming (K & P)
Joel on Software
link|flag answered Dec 30 '08 at 0:31
Fortyrunner
4,287619



0
Mythical man Month
Essential COM by Don Box, if you are a COM Programmer
Art of Computer Programming
SICP
link|flag answered Dec 30 '08 at 1:16
Vinay
1,852418



0
The Martian Principles It's very short and very much to the point. Teaches you a lot of the things that you can do wrong when building an application. Many of the books on this list are advanced, but they're also not real practical. Martian Principles is something you can use every day to help you build more bullet-proof code.
link|flag answered Dec 31 '08 at 2:31
jcollum
3,297527



0
I would think someone would have mentioned The Lions Book by now

Don't assume it - prove it. In other words: don't base critical work on unverified assumptions. Make sure the foundation is sound.

Don't assume it - prove it. In other words: don't base critical work on unverified assumptions. Make sure the foundation is sound.

http://stackoverflow.com/questions/806659/what-are-the-best-habits-of-highly-effective-programmers

set up another DocumentRoot other than the default global one

set up another DocumentRoot other than the default global one

一般 vhost 完整的設定 裡面會包含 Directory 的權限設定
沒有的話會是繼承 httpd.conf 裡面的

# vi /etc/httpd-vhosts.conf
### [START] for FTP

  ServerAdmin webmaster@dummy-host2.example.com
  DocumentRoot "/home/ftp/ftp_user0/www"
  ServerName ftp.example.com
  ErrorLog "/var/log/apache/ftp.example.com-error_log"
  CustomLog "/var/log/apache/ftp.example.com-access_log" common

  #php_flag register_globals On

  
    ### Turn off php
    php_admin_flag engine off
    
    Options -ExecCGI

    #AddType text/plain .html .htm .shtml .php

    #Options Indexes FollowSymLinks

    #Options +Indexes FollowSymLinks +ExecCGI
    #AllowOverride AuthConfig FileInfo

    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all
  

### [END] for FTP

Make sure www user has the read access to the /home/ftp/ftp_user0/www. Please do check following permission of each path

# ls -ld /home

# ls -ld /home/ftp
dr-xr-x--- 6 ftp ftp 512 Jun 29 09:28 /home/ftp

Note: the path above, www user has no access to the /home/ftp directory, so I added www user to the ftp group.

Add www user to the ftp group
# vi /etc/group

Restart Apache
# apachectl stop

# apachectl start

===============

Star:
apache2 預設的話 httpd.conf 裡面應該有一行是 Include etc/apache2/Includes/*.conf

這行的意思跟 php 的 Include 是一樣的
不過他可以用 萬用字元
所以 Include 底下只要是附檔名為 .conf 都會載入

以小築的機器而言 因為是多人共用像我就會在 Include 的目錄底下建一個自己的 vhost.conf 檔 如 myName-vhost.conf
還有 etc/apache2/Includes/*.conf 事實上他的 載入順序是依照 一般英文數字的排序順序載入 如果你 Includes 下有 0.conf 就會比 myName-vhost.conf 還要早載入

Monday, June 28, 2010

How to register a variable for used in page.tpl.php?

How to register a variable for used in page.tpl.php?

<?php
function YourModuleName_preprocess(&$vars, $hook) {
  if ($hook == 'page') {
    $vars['hello_world'] = 'Hello World';
  }
}
?>

add following line to sites/all/themes/your_theme/page.tpl.php
<?php print $hello; ?>

Reference: http://drupal.org/node/223430

Thursday, June 17, 2010

Monday, June 14, 2010

slide show moving picture small large

tooltip.js
function simple_tooltip(target_items, name){
  $(target_items + " img").each(function(i){
    $("body").append(
      "<div class='" + name + "' id='" + $(this).attr('id') + i + "'><p>"
      + $(this).attr('alt')
      + "</p></div>"
    );
    
    var my_tooltip = $("#" + $(this).attr('id') + i);
    
    $(this).removeAttr("alt").mouseover(function(){
        my_tooltip.css({opacity:0.8, display:"none"}).fadeIn(400);
    }).mousemove(function(kmouse){
        my_tooltip.css({left:kmouse.pageX+35, top:kmouse.pageY+35});
    }).mouseout(function(){
        my_tooltip.fadeOut(400);
    });
  });
}
 
$(document).ready(function(){
  simple_tooltip("#img_zone", "tooltip");
});

test.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>slide show moving picture small large</title>
<style>
.tooltip{
position:absolute;
left:-2000px;
background-color:#dedede;
padding:5px;
border:1px solid #fff;
width:620px;
}

.tooltip p{
margin:0;
padding:0;
color:#fff;
background-color:#222;
padding:2px 7px;
}
</style>

<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type='text/javascript' src='tooltip.js'></script>
</head>

<body>

<marquee behavior="scroll" direction="left" width="500" scrollamount="3" onmouseover="this.stop();" onmouseout="this.start();">
<div id="img_zone">
 <img id="img1" src="1_small.jpg" alt='<img src="1_large.jpg"><br>test1'>
 <img id="img2" src="2_small.jpg" alt='<img src="2_large.jpg"><br>test2'>
 <img id="img3" src="3_small.jpg" alt='<img src="3_large.jpg"><br>test3'>
</div>
</marquee>

</body>
</html>

Saturday, June 5, 2010

從今以後,不再被人左右

從今以後,不再被人左右

當 求知慾(全心投入) 大於需要人慰藉 (有人可以依靠/傾訴),或說全神貫注(專注)在某件事時,即不再需要人慰藉

Valgrind Programming Tool, Memory Debugger, Memory Leak, Performance Analysis, Debugging, Julian Seward, GNU General Public License

Valgrind Programming Tool, Memory Debugger, Memory Leak, Performance Analysis, Debugging, Julian Seward, GNU General Public License

http://valgrind.org/

Thursday, June 3, 2010

flash swf embed menu problem

<?php
<embed src="" width="" height="" wmode="Opaque">
?>

wmode - Possible values: window, opaque, transparent. Sets the Window Mode property of the Flash movie for transparency, layering, and positioning in the browser.

window - movie plays in its own rectangular window on a web page.

opaque - the movie hides everything on the page behind it.

transparent - the background of the HTML page shows through all transparent portions of the movie, this may slow animation performance.

Tuesday, June 1, 2010

Drupal Caching

Drupal Caching

If your content was all static you would not need Drupal. However even the most dynamic of web sites have content chunks that are repeatedly shown to the users, and that’s where caching comes in.

Beyond Drupal – before we begin.

This post does not cover database-level query caching or PHP opcode caching: those are two separate topics deserving an analysis by experts. For those curious about the subject, there is an excellent presentation “Accelerating PHP Applications” (the only option it misses is my beloved eAccelerator).

memcached is another interesting mechanism: it works very much like a database cache, but it can be shared over a network (imagine a “cache server”), and it does not suffer from mySQL’s habit of dropping a table’s cache every time the table is changed. There is a price though: it’s up to you to make sure that memcached data has not grown stale. There is a module for using memcache with Drupal instead of the standard cache.

Drupal itself has several built-in and optional caching mechanisms, so I decided to sort it out here.

An ode to Drupal developers: much thinking and discussion has gone into the impossible task of creating this infinitely configurable yet still speedy CMS. Before you complain, check out the prior discussions and efforts like this, and then go ahead and propose an improvement (if you are in it just for the impotent bitching, go buy yourself a commercial product).

As of version 5.0 Drupal enjoys a pluggable cache system.

What is cached by Drupal?

  • sessions
  • variables
  • menus
  • blocks (not by default)
  • nodes ( = content) and comments

It would appear that the site admin cannot directly control caching of sessions and menus.

Partial Solution: DEVEL module has in its block an “Empty cache” item. This is a “total purge” option: it clears all caches. Very useful for developers.

Standard Drupal Caching assumes that only logged-in users need to see up-to-the-second content, and so the nodes (but not the blocks) seen by the casual visitors are cached.

“Aggressive” caching option is incompatible with many modules, and does a very good job ofmaking the danger clear to the admin. If just one of your modules is incompatible with aggressive caching, you have to switch it off.

However, this compatibility test is not perfect. It is possible for a module to raise the flag, yet pose not danger to aggressive caching (this has to do with some contributors using a potentially invasive hook for rather benign, yet extremely useful, applications). So, if you discover that your favorite module is “incompatible” with aggressive caching, do check around before mourning.

The cache itself can be a source of a slowdown: the most popular mySQL engine, myISAM, does table-only locking, and if your site really grows it will become a problem. The solution for large traffic sites is to move often updated tables to INNODB or similar engine.

Throttling is the ideological opposite of caching: instead of showing your content faster, it throttles (switches off) some blocks when you site is under high load, thus making Drupal work less. Throttling is built into the standard distribution, but you have to enable it on per-module basis (under Site Building -> Modules). It is a good last line of defense.

Contributed Modules

Block Cache

This module creates a cached version of each block. Block caching happens separately from page caching and so it will work for logged-in users whether or not page caching is enabled for the site. Cached blocks make just one call to the database and can therefore reduce the overhead required to render blocks that require complex queries and/or calculations such as some Views or Taxonomy-related blocks.

The module is very flexible in terms of fine tuning. I have yet to hear about a high volume site that does not use it for at least some blocks.

fastpath_fscache

This module uses Drupal’s pluggable cache system, but instead of a database it caches static pages as local files. This can give yor site one hell of a performance boost.

The cached pages are intelligently expired when the page contents are updated. However, block updates are not caught in the same manner, which is why the module also enforces a regular cache expiration triggered by cron. This means that as far as the visitors are concerned, the content of the blocks on your site will change only so often (once and hour if your cron runs every hour, more often if you shorten your cron gaps). – It’s a classic trade-off of speed versus flexibility. You decide what your needs are.

Boost

On the surface Boost is very similar to fastpath_fscache. It uses file caching and has been documented in great detail here, here, and here. Boost uses same pluggable cache system and, just like other modules, limits its field to the anonymous users, but architecturally its author has intentionally left space for caching for the logged-in users (possibly with personal per-user cache). – I am vary curious what comes out of this.

Boost promises higher performance than similar fastpath_fscache because it uses Apache mod_rewrite so that when a new request arrives, if the page has already been cached Apache serves it out without ever touching Drupal. So for non-authenticated users it’s just Apache serving static pages bloody fast. (The downside is that you cannot run it on Windows or on any Web server that does not fully support mod_rewrite. Sorry.)

It is also possible to have Boost file cache shared by several Web servers in a cluster, over, say, NFS. (Just remember to balance the IO).

There has been an interesting report of Boost working together with Memcache module where Boost handled anonymous user pages and Memcache took care of the logged-in users.

APC – Alternative PHP Cache

APC is two things. First it is an opcache and second it is a memory based cache. This module only handles the latter. This module overrides the built in caching in Drupal and uses memory based caching instead of database based caching.

Many people love and use APC – it is reliable and mature.

The only questions I would have before installing this module are:

  • can I also use APC as an opcode cache? How?
  • will it interfere with a different opcode cache?

Memcache API and Integration

The concept of memcache is deceptively simple: it’s a daemon that listens on a TCP port and accepts (or serves) key/value data. The data itself is stored in RAM. That’s it.

From this simple idea great possibilities arise, allowing to replace/augment a database cache, create and manage multiple cache “buckets” shared among clustered servers over a network, et cetera, et cetera.

The Drupal module takes an existing Pecl extension and plugs it into Drupal’s caching interface. Since the interface is standardized, memcache plays nicely with Boost and Advanced Cache (see below).

Even more importantly, it does not force you to give up your database cache – you can still have both (thus feeling safe about a power outage).

The installation looks scary, but it really is not as long as you follow the instructions. And the effort is worth it, since memcache can help you with some items not handled by file cache solutions, and thus improve logged-in user experience.

Advanced Cache

The advanced caching module is mostly a set of patches and a supporting module to bring caching to Drupal core in places where it is needed yet currently unavailable. These include caching nodes, comments, taxonomy (terms, trees, vocabularies and terms-per-node), path aliases, and search results.

Without Advanced Cache module, once a user logs in, the caching stops, because the content is considered too user specific to cache effectively. Just think of all the permutaios of blocks, personalization, keywords and stats! Now add the dangers of accidentally giving users access to cached content they are not authorized to view: a disaster in the making!

Advanced Cache patches Drupal to add very sophisticated cashing of information “atoms”, and keeps track of a whole lot of relevant restriction data. In my honest opinion, this functionality truly belongs in Drupal Core.

The module not only allows you to improve the experience of your logged-in (i.e. regular) users, it actually works well with the existing caching backends like memcache.

The installation is not for the timid, but if you are building a highly (but not overly) dynamic site with lots of logged-in users… you got to consider Advanced Cache.

The Bottom Line

  • Caching cad do miracles and turn an apparently sluggish site into a playground of joy.
  • You can apply caching outside Drupal: at the Database, for PHP code, and in the Web Server (see Apache2 mod_cache).

In Drupal:

  1. Start by playing with built in cache (basic and advanced) and throttling
  2. Deploy Block cache (intelligently!)
  3. For a site with lots of anonymous visitors consider fastpath_fscache.
  4. For a more sophisticated installation, Boost is its bigger brother.
  5. For memory caching APC is very straightforward.
  6. Memcache is state of the art, but you must be prepared to actually focus on the deployment – it is not a 3-minute fix.
  7. Advanced Cache, possibly with memcache (and even Boost?) is as sophisticated as it gets these days. But if only few of your visitors ever log in, it may be an overkill. Think of it this way: are you desperate enough to patch the core code?

I’d love to know what worked for you. Drop me a note!