source: products/vendor/Products.CacheSetup/current/docs/archive/audiences.rest @ 3358

Last change on this file since 3358 was 3296, checked in by fenix, 13 years ago

Load Products.CacheSetup?-1.2.1 into vendor/Products.CacheSetup?/current.

File size: 41.5 KB
RevLine 
[3296]1
2[August 15, 2007 - archived for future reference - newbery]
3___________________________________________________________
4
5
6NOTE: This documentation is not yet finished. It's included here as it
7may be useful in its current state; it is likely to be finished and
8checked by around April 10, 2006.  - Joel Burton
9
10
11==================================================
12What People Need to Know About CacheFu By Audience
13==================================================
14
15CacheFu is a set of technologies meant to allow Plone sites to perform
16significantly faster, while still showing content and navigation that is
17up-to-date with the changes being made by content editors.
18
19It does this by combining several existing products and adding a lot
20of configuration controls. With few or no changes, most sites will experience
21significant performance increases, and, with tuning, many sites can
22experience even more significant increases.
23
24--------------------------
25An Introduction to Caching
26--------------------------
27
28A smart program like Plone will always be a bit slow. This isn't an
29oversight on the part of the developers, but is a side-effect of all
30the work that Plone does for you when it gets a request for a page.
31
32Imaging a user requesting a page, ``/newsitems-project-a``, from your
33site. Plone has to:
34
35- Check if this user is logged in, and, if so, if their login credentials
36  are good (remember, the web is a "stateless" protocol--each request for
37  a page or an image is essentially a separate thing, and must be considered
38  and checked independently).
39
40- Find the object in the object database.
41
42- Check that the user has rights to that object (and to everything else
43  mentioned here, like the skins, scripts, etc.)
44
45- "Skin" the image by applying page templates to it.
46
47- Perform any logic required (for example, the portlet on the right that
48  shows the calendar must search across all events to decide which ones
49  are in the current month, and show them on the calendar).
50
51- Add custom information about the user (user bar links, their name,
52  preferences, etc.)
53
54- Decide which JavaScript and CSS files to reference.
55
56- Create dynamic left-hand navigation, global section tabs across the top,
57  etc.
58
59- Figure out which portlets to show, and show them.
60
61- and more!
62
63This is a good thing--all this checking and dynamic stuff is what makes Plone
64rich and easy-to-use. However, it means that, out of the box, Plone can only
65serve a few web pages in a second on most servers. For lightly-trafficked
66sites, this may be acceptable, but for more popular sites, this means that
67users may have to wait a second or more to get back their page, making for a
68slow experience.
69
70One excellent solution to this is caching--having Zope/Plone and other programs
71work together to decide which parts of that workload don't need to be performed
72every time, and use the old results (for those that aren't used to the idea,
73a real-world cognate is your friends' phone numbers: you could look them up
74in the phone book *every time* before you call them, but, to make things
75more faster and more pleasant, you only do that if you know it changed or if
76you've forgotten what the number was).
77
78Done correctly, caching is a tremendous benefit--the site runs much better
79and no one notices anything different. Done incorrectly, users become
80frustrated that things don't change as expected--they add a news item,
81and, moments later, they visit the folder where they added this, and
82the news item isn't shown in the contents listing. This is a "stale" result--
83the user experiencing something old.
84
85Sometimes, some degree of staleness is an acceptable trade-off. For example, on
86a site with a portlet that shows the weather, you probably don't want to
87contact the government weather server 600 times a minute to see if the weather
88forecast really changed. Instead, you compromise by checking only every 5
89minutes (or 5 hours or whatever); users can get slightly older weather reports,
90but it's a worthwhile trade-off for performance.
91
92Out of the box, CacheFu does *not* make these compromises for you,
93except in one or two very small areas. You can trust that it works
94hard to get you the most up-to-date content it can, even if it means
95your server might be doing a bit more work that is the possible
96low-point. For those who want more control, this document will help
97them understand how to turn those knobs.
98
99---------------------------
100Where Things Can Get Cached
101---------------------------
102
103Essentially, there are three broad places web pages or parts of web
104pages can be cached:
105
106- **Inside Zope**. This data is cached inside Zope, meaning that Zope
107  still creates and serves the web page directly, but it may not have
108  to perform some time-consuming calculations every time. Generally,
109  inside-Zope caching has the least dramatic speed benefits, but when
110  content changes, it is easy for Zope/Plone to realize this and begin
111  serving new content.
112
113- **On a proxy server / caching appliance**. These type of programs
114  stand between the web browser and Zope. When the user, Jane,
115  requests a web page, her request actually goes to the proxy server.
116  This server decides whether or not to pester Zope to produce the page
117  or image. In many cases, the proxy server has this information already,
118  and serves it to Jane. This is much faster, since proxy servers tend
119  to be heavily optimized for this operation. In cases where the proxy
120  server can't serve the content directly to Jane, it will pass that
121  request to Zope. In some cases, the proxy server will be told that,
122  in the future, it can serve this directly, and it was cache this response,
123  and will handle it directly in the future.
124
125  Squid is a very popular, open source proxy server, and CacheFu is optimized
126  to work with Squid. Apache, while being a more general, very extensible
127  web server, can also handle caching. Apache does not have the features
128  that Squid has, though, for "purging"--getting rid of content that is
129  no longer as up-to-date as it could be. Therefore, Apache can be used
130  to proxy cache for certain things, but CacheFu will not be able to use
131  it to as much of an advantage as Squid.
132
133  It is advantageous, then, for medium- and large-traffic-sites to
134  use Squid. Smaller sites will get some benefit, too, but these
135  benefits may be less required, and may not justify the addition of a
136  new piece of software.
137
138- **In a web browser**. Almost all web browsers (and all the well-known,
139  popular ones, such as Internet Explorer, Firefox, and Safari) can cache
140  web pages and images themselves. When they do this, they are able to
141  respond themselves to repeated requests for that same image and page.
142  This is obvious incredibly fast--since the request and web response
143  doesn't even have to go across the network at all, and, in some cases,
144  neither Zope nor a proxy server will have any idea that there was even
145  a request for it.
146
147  The general challenge with browser-side caching is that there's no
148  mechanism to let every possible web browser know that they should let go
149  of those pages they've been holding onto (it's not feasible to try to send
150  out a purge request to everyone that visited your site, and practically
151  no browsers even support this feature, anyway). As such, the kind of content
152  that CacheFu caches this way will tend to be things that it knows the
153  browser can cache without any risk of that content becoming stale.
154
155In addition, there are four other common places where caching might happen
156in the Zope/Plone world:
157
158- **In a ZSQL method or in a database**. In cases where you have connected
159  Plone to a relational database, you can tell your ZSQLMethod (the component
160  of Plone that is an SQL request) to cache the result of that database
161  request. So, for instance, in an application that lists stock prices, you
162  could opt to only query the database once every 5 minutes, even if the
163  SQL method was called every second.
164
165  Similarly, some databases themselves have their own mechanisms for caching
166  requests and responses; Zope is not involved or even aware of these.
167
168- **In authentication against LDAP/Relational Databases/etc.**. Plone can
169  authenticate users against special storages for user data, most commonly
170  LDAP servers and relational databases. There are different add-on products
171  for these different kinds of servers.
172
173  These add-on products sometimes include features that cache the authentication
174  itself--that is, they don't try to memorize the result of getting a page,
175  or what an image looks like, but they cache the fact that "joelburton" *is*
176  a user of your system, that the password "jUnER0x!" is my password, and
177  that I am a Manager on your system. Rather than pestering the LDAP server
178  on _every_ request, the software caches this information, and trusts that I
179  haven't been fired in the last 5 minutes from your staff.
180
181- **ZODB caching**. The Zope Object Database (which normally holds all the
182  Plone content) itself caches those objects. In other words, when someone
183  requests to see the content item at ``/news-items/project-a``, the ZODB
184  will hold on to that for a few minutes, and, for further requests, will
185  just use the in-memory copy. This is just the "raw" object--not the result
186  of calling it, skinning it, or anything else. This kind of caching is
187  "transparent"; it is never stale, and is never a bad thing to have.
188
189- **ZEO caching**. ZEO is a technology for scaling large Plone sites across
190  multiple servers, by separating the object storage onto one server, and
191  the application server onto other(s) (though they can both be on the same
192  server, and other configurations are possible). ZEO itself will tell the
193  individual application servers that it's ok to cache requests for an object
194  (again, /news-item/project-a), so that, if that same Zope application server
195  needs it, it can use it's private copy. This caching is very similar to the
196  ZODB caching, above (it's essentially a networked copy of the same idea),
197  and has the same transparent, always-beneficial characteristics.
198
199None of these four types of caching are used or affected by CacheFu. The latter
200two are perfectly transparent and never affect anything. The first two are
201very application specific--they're turned on by programmers and site-builders
202specifically. CacheFu won't disable these or enable these itself, and the
203caching CacheFu provides will be *on top of* whatever benefits
204these provide.
205
206-----------------
207Primary Audiences
208-----------------
209
210CacheFu, and caching in general, can be quite complex--for those who want
211or need to understand this complexity. Rather than trying to teach everything
212to everybody, this section teaches the concepts for different audiences.
213People building sites in Plone need to know less than people who build
214complex products for others to use; people who deploy ordinary sites need
215to know less than people who deploy enormous sites with thousands of users
216or more.
217
218End Users
219=========
220
221End users of the site (the people who use the site, but don't create
222content or design the skins, etc.) need to know nothing about CacheFu,
223nor do they need to make any changes in their browsers. CacheFu already
224sends out the right commands (caching headers, as they're called) to
225say things like "don't cache this, even if the browser normally wants
226to cache things".
227
228.. tip::
229
230    With the standard install, there's only one case where users (only
231    anonymous users) might
232    see stale content. When a user is looking at a page (say,
233    ``news-items/project-a``, Plone will normally show navigation on the
234    left-hand side that might include "sibling items"--other items in
235    the ``news-items`` folder. *If* you are using Squid, it will serve
236    cached pages to anonymous users, and the cached copy of ``project-a``
237    might show navigation that doesn't include the newly-created ``project-b``
238    news item. This only happens with anonymous users, and only when Squid
239    is involved (because CacheFu tries to cache things most aggressively in
240    these cases).
241
242    This case "times out" after an hour--even if nothing else changes,
243    CacheFu has told Squid to not serve ``project-a`` for more than an hour
244    without re-checking, and so it will, at the very latest, pick up the
245    new ``project-a`` page showing ``project-b`` in the left-hand navigation
246    within an hour.
247
248    If you can't tolerate this experience, you could reduce the window
249    of time to less than an hour, or, if you absolutely need 100% up-to-date
250    navigation for sibling items, you can turn off Squid caching for this case,
251    (covered later).
252
253For logged-in users, there are no stale content opportunities with the
254standard settings: non-anonymous users never have their content pages
255cached in Squid by CacheFu's default settings.
256
257Content Managers
258================
259
260For the people who edit content, there's nothing they need to know,
261except for the warning about stale sibling items in "End Users", above.
262The content managers themselves, won't experience this, but the users
263who use their content might.
264
265If a content creator sends a link to newly-created content, everyone will
266be able to get to it (assuming, of course, they have the right permission
267to do so). However, should a content manager send out a link to
268``news-items/project-a``, that page might not show the even-more-newly-created
269``project-b`` in the navigation for anonymous users, as described above.
270
271ZMI Customizers
272===============
273
274This audience makes up the bulk of people who build Plone sites and
275customize them. It includes people who do things like:
276
277- customize templates and CSS
278
279- write Python Scripts and use External Methods
280
281- make setting/configuration changes, like changing how the navigation
282  displays, etc.
283
284It's important for you to understand that you don't have to change *anything*
285to get many of the benefits of CacheFu, but, as you write new portlets,
286or skins, you may need to adjust the settings in the product to continue to
287not get stale pages.
288
289First, let's look at the general configuration for CacheFu.
290
291Cache Configuration Tool
292------------------------
293
294Most of the settings for CacheFu's technologies are set in the "Cache
295Configuration Tool"; found in `Site Setup -> Cache Configuration Tool`.
296
297This tool has five tabs:
298
299- "Cache configuration tool". This is where broad configurations to the
300  behavior are made.
301
302- "Caching rules". This tab allows you to determine what kind of caching
303  is chosen for different situations.
304
305- "Caching header sets". This tab allows you to decide exactly how
306  the caching rules get carried out.
307
308- "Page cache". This allows you to clear the in-memory storage of
309  some kinds of cached content.
310
311All of these are described below in more detail.
312
313Cache Configuration Tool Tab
314++++++++++++++++++++++++++++
315
316Cache configuration
317  CacheFu can be used on a site that is "Zope only". This means that no
318  proxy server (either Apache or Squid or anything else) is sitting in
319  front of Zope.
320
321  In this case, things can be cached in Zope, or in a web browser.
322
323  If, however, you put your Zope behind Apache (or any other non-Squid
324  caching proxy), CacheFu can send out headers to tell the
325  proxy server to cache JavaScript, CSS, etc.
326
327  If you're behind Squid, CacheFu can send out headers to cache those
328  things as well. Plus, since Squid support "purge requests" (to let
329  go of cached content and get it fresh), CacheFu can also send out
330  headers to tell Squid to cache many more pages, since it can selectively
331  clear those from Squid's cache as needed.
332
333  In some cases, your organization may want or need to use Apache
334  (as a very full-featured web server, it can do things that Squid can't,
335  and has dozens of add-on products). However, you may still want to
336  get the benefit of Squid. This is a case to use the "Zope behind
337  Squid behind Apache" setting: the public talks to your Apache server
338  (which might also handle things like PHP applications). Requests
339  for anything on the Plone site are delegated to Squid, which
340  can either respond itself or further delegate to the actual Zope/Plone
341  server.
342
343  If you are going to run with Squid, either by itself or behind Apache,
344  be sure to read the "Setup with
345  Squid" section, below, for important information on how to configure
346  Squid.
347
348  If you are going to run with Apache, you will need to have a few
349  settings in your httpd.conf virtual host block -- see below.
350
351  If you are running your Zope site by itself, there are no special
352  configurations required.
353
354Site Domains
355
356  In order for CacheFu to be able to tell Squid to purge a cached page,
357  CacheFu needs to know the domains that Squid might have that page under.
358
359  For example, if you're serving `www.example.com`, a cached page,
360  `about-us` could be at http://www.example.com/about-us. Depending on
361  your Squid (or Squid+Apache settings), people might also be able to
362  visit http://example.com/about-us (note the missing "www") and find the
363  same page.
364
365  CacheFu will need to tell Squid separately to purge both of those URLs;
366  while CacheFu understands that this is the same page, Squid has no idea
367  that these two pages are the same thing, and must be told separately.
368
369  Therefore, you'll want to list **all** of the domain names that your
370  site is reachable at. Be sure put the port number at the end, even for
371  port 80, and don't forget to include `https://example.com:443` and
372  `https://www.example.com:443` if you run on HTTPS, too.
373
374  Please note that port numbers here are *the ones that the public visits*,
375  not where your Zope instance is really speaking. Most Zope servers
376  serve content themselves on port 8080 (8282 is common on Mac OSX); however,
377  as far as Squid is concerned that content was asked for on port 80,
378  since that was the original request.
379
380  If you're not using Squid, you can keep this empty. Values entered here
381  are only meaningful if you chose "Squid" or "Squid behind apache" above.
382
383Squid URLs
384
385  If you're running Squid and Zope alone, Squid normally answers web
386  requests from the outside world on port 80. Therefore, CacheFu knows
387  how to reach Squid (on port 80) to send purge requests. You can
388  leave this blank.
389
390  In some cases, you're not running Squid on port 80. Most likely this is
391  because you're running Squid behind Apache, and you run Apache on port 80 so
392  it is the first server to handle the request). In this case,
393  you need to tell CacheFu how to reach Squid to send purge requests.
394  Normally, this will be `http://127.0.0.1:3128`, the address and port number
395  to reach Squid on the local box.
396
397  If you are running Squid on a different box, or on a different port number,
398  you'll want to enter that instead. If you have several Squid instances,
399  you'll want to list *all* of them so that each purge request can be sent
400  to each one.
401
402Compression
403
404  Separate from caching, CacheFu can also compress web pages.
405
406  This compression is a standard part of the HTTP/web technologies: pages
407  can be sent compressed with "gzip compression", and most web browser can
408  receive the compressed page, uncompress them, and render them from the
409  user.
410
411  You can choose to "Never" do this, which is the safest option--you won't
412  have any browser incompatibility issues to worry about.
413
414  You can choose to "Always" do this. This is an **unusual choice, and
415  probably not correct**--some browsers can't deal with gzipped pages, and
416  always sending them will not allow people with these browsers to use your
417  site.
418
419  You can have CacheFu decide on a case-by-case basis depending on what
420  the web browser sent for the "Accept-Encoding" header. This header is
421  sent by web browsers to indicate what kind of content that can receive
422  back. If the browser indicated that it can receive gzipped content, this
423  will send it gzipped.
424
425  You can have CacheFu decide based on both the "Accept-Encoding" header
426  and the "User-Agent" header. "User agent" refers to which web browser
427  the browser says that is. If this option is selected, CacheFu looks both
428  to see if the web browser *says* if can handle gzipped content, and,
429  just to be safe, it checks that it is a browser that CacheFu knows can
430  do this successfully (some early versions of Netscape are buggy for
431  this!).  Checking the user agent comes at a high cost: squid will
432  need to cache separate versions of each of your pages for every
433  single browser / operating system combination, which will make cache
434  hits much less likely and will increase the disk space required by
435  squid by a factor of 20-100!  Using Accept-Encoding is the
436  recommended practice, since the buggy browsers are rarely in use.
437
438Vary Header
439
440  In order to not serve stale content, cache systems (either proxy caches
441  like Squid or in-browser caches) need to know more than just the URL
442  of the object. Returning a cached copy of `http://example.com/about-us`,
443  for example, might be wrong if the user prefers to speak Greek, and
444  the cached copy is the English version.
445
446  Therefore, in this field, you can list all of the values that are
447  understood by browser/cache proxies for "varying" these results.
448
449  For example, if the Vary header is just "Accept-Language", and a
450  request comes for `http://example.com/about-us`, your cache program
451  will cache it *while keeping track of the Accept-Language value it
452  received from the browser*. Then, when another request comes, it
453  will make sure to hand back the cached copy only if the
454  Accept-Language value for the new request is the same as the
455  old. Otherwise, it will cache this second copy, and hand that back
456  only for the same URL and Accept-Language header.
457
458  If your site has multilingual capabilities, you'll want "Accept-Language"
459  in here. This will make sure you don't return the English copy for the
460  Greek speaker.
461
462  If you don't have any multilingual content, and you don't even want
463  the standard Plone templates to be returned in other languages (which you
464  can prevent by removing PlacelessTranslationService from the products),
465  you should remove this. Keeping this value in would mean that your
466  caching systems are keeping a separate copy of a page for Accept-Language=en
467  (English speakers) and a different copy for Accept-Language=gr (Greek
468  speakers) *even though* the pages themselves don't vary based on language.
469  Should you fail to remove this, you will use up more memory for caching
470  (and have an occasional request go to Zope that could have been answered
471  from caching) more often than is necessary.
472
473  If you allow compression (see above), you'll want to add "Accept-Encoding"
474  here. This will ensure that you don't consider a gzipped version of a page
475  and a non-gzipped-version to be the same thing. In other words, we'll
476  cache two copies of each page: one for people who say that can accept gzip,
477  and others for those who can't.
478
479  If you have a multilingual site *and* allow gzipping, you'll want to
480  leave both in.
481
482Caching Rules
483+++++++++++++
484
485Caching rules are part of the core concepts of CacheFu. They are a set
486of rules which are analyzed for each web request that gets to Zope,
487and, if the rule matches the request, the caching rule puts its
488behavior into effect.
489
490For example, if a web browser gets some CSS, and this request gets to
491Zope (i.e., it isn't answered by Squid or other places), the request
492goes through the rules here, in order (top to bottom) until it matches
493one rule. That rule that matches can do things like:
494
495- Cache the page in memory in the ZODB
496
497- Request that headers be sent out with the response. These headers
498  are interpreted by browsers and cache proxies to say things like
499  "keep this in your cache for 1 hour" or "never, ever cache this"
500  (for some details on headers, see the next section).
501
502Since we take the first rule that matches, only one can ever apply to
503any given request. If no rule matches, no particular action is taken,
504and the content is still rendered and returned normally.
505
506Let's walk through the rules that CacheFu ships with. Understanding
507them will help you understand what CacheFu does.
508
509HTTPCache
510  This cache is never matched (FIXME: not sure what this means?) out-of-the-box for CacheFu, but, if you
511  customize things, can be quite useful.
512
513  It is used if there are places where you have pages (or images, such
514  as your site's logo) that can be *entirely* cached and do not
515  require any invalidation. Consider a site with a page that _always_
516  looks the same, regardless of whether you're logged in or not, and
517  which doesn't need to be purged when any content changes. A good
518  example might be a page like that pops up with static help about your
519  site, and doesn't show content, rely on content, or change based on
520  your login status.  For this example, that page would be a Page
521  Template called `site-help`.
522
523  To tell CacheFu that this page can be cached like this, you'd
524  need to associate it with the "HTTPCache" cache manager. For
525  example, we could go to our `site-help` template and, under the
526  Cache tab, associate it with the HTTPCache.
527
528  Traditionally, to do this in Zope, you'd be associating the
529  PageTemplate with a cache called "HTTPCache" which is an
530  "Accelerated HTTPCache Manager", and that manager sets the headers itself.
531  In CacheFu, however, HTTPCache doesn't do anything itself--it's
532  essentially a "marker" to indicate that a piece of content *can*
533  be cached like this, and therefore, it's picked up by this rule.
534
535  Since no content types are selected in the box below, all
536  types of content work can meet this rule (assuming, of course,
537  they're associated with the HTTPCache).
538
539  Several options aren't used here (& will be discussed where they
540  are used, later).
541
542  The two boxes for headings for anonymous users and headings for
543  authenticated users are the primary "outcomes" for rules, and this
544  is the case here: content that meets this rule is, by default,
545  matched to the cache-in-browser-for-24-hours rule, both for
546  anonymous and logged-in users. If you wanted to cache this stuff
547  just for 1 hour, you could change to the cache-in-browser-for-1-hour
548  rule. If you wanted a different possibility (say,
549  cache-in-browser-for-10-mins), you'd have to create this in
550  the caching header sets tab, described below.
551
552  The last choice, "Last-Modified Expression" is the expression that
553  will be used to decide when this content was last modified; this is
554  used so that CacheFu only caches it for 24 hours beyond that (or
555  one hour, or however long you chose).
556
557Content
558  This rule is used to cache displays of normal (non-folder,
559  non-image content), like a News Item.
560
561  By default, the normal Plone content types are cached by this; you
562  don't have to associate them with any cache manager, like we did
563  above.
564
565  The content types that are matched by this are selected in the
566  content types box. These are those content types that aren't
567  File or Image (those are handled separately) or folderish thing
568  (those are also handled separately).
569
570  Of course, we don't really want to cache the news item *itself*--
571  that's not sent to web browsers. Instead, we want to cache the
572  HTML view of a news item.
573
574  The "Default view" box, when checked, means that this rule will be
575  in effect when a request is made for a skin object (Page Template,
576  Python Script, etc.) for the content types listed *if* that
577  skin object is the default view for that content type. So, for
578  example, it will catch::
579
580    http://news-items/project-a
581
582  and ::
583
584    http://news-items/project-a/newsitem_view
585
586  since ``newsitem_view`` is the default view for news items. It
587  won't catch ::
588
589    http://news-items/project-a/special_newsitem_view
590
591  Should you want to cache additional views, like
592  ``special_newsitem_view``, you should add that to the
593  "Templates" field, which is for the ids of additional skins
594  that should be cached.
595
596  "Cache Templates" in memory means that, in addition to whatever
597  else kind of outcome we would have for things that match this
598  rule, we should cache the template results in memory. This helps so
599  that, even if you have no proxy cache, CacheFu can still work with
600  the in-memory cache.
601
602  Note that ::
603
604    http://news-item/project-a
605
606  and ::
607 
608    http://news-item/project-a?form_var=1
609
610  are different requests, and, as such, will be cached separately.
611 
612  "Cache Preventing Request Values" is used to specify those form
613  variables (or other things in the request object) that, if present,
614  should signal that this request should not be cached. By default,
615  "portal_status_message" is listed here, plus "statusmessages", which
616  is the name of the cookie that's getting used with recent 2.5 and
617  3.0 plone versions. "portal_status_message" is the request variable
618  used to hold the feedback messages (usually shown in bright orange,
619  at the top of pages). Since the same template can be shown with
620  dozens of these feedback messages ("Changes saved", "Content added",
621  "Email sent", etc.), it would be expensive to cache each copy
622  individually, and probably not that helpful, since not many people
623  would want to see the exact same page, anyway. Therefore, if there
624  is an status message being sent, CacheFu won't cache this page.
625
626  "Predicate" lets us add any arbitrary TALES expression as a further
627  check for whether this rule matches. A request would have a) be
628  skinning a content type listed in the content types, b) be for a
629  default view (if that's checked) *or* be an explicitly-named
630  template, c) not have a `portal_status_message` (or `statusmessages`
631  cookie) and d) pass this expression to match.
632
633  "Header Set for Anonymous Users" is set to have the proxy cache
634  (Squid, usually) receive the message to cache this for 1h. For
635  logged-in users, it's cached with an ETag, a
636  mechanism that allows it to be cached in ways that cause changes to
637  request a fresh copy.
638
639  .. tip:: ETags
640
641    ETags are a mechanism that is a HTTP/web standard for web browsers
642    and servers to pass around some information that represents "other
643    information" about a request. This information can include things
644    like: the kind of user that requested it, the date it was last
645    changed, etc.
646
647    So, if you request ::
648
649      http://news-items/project-a
650
651    the server might give this back to you with an ETag of ::
652
653      ETag: joelburton-2006/12/25-en
654
655    Which means that this request was for Joel Burton, the content
656    was modified on Christmas, 2006, and it was in English. The cache
657    program (be it in the browser of cache proxy) will store this ETag
658    along with the content. (Note: this isn't the exact format that
659    ETags appear in, but the concept is accurate).
660
661    Now, the browser wants to re-request this page from Zope, it will
662    get that old ETag and give it to the Zope. Zope will look at it
663    and compare it with the current ETag it would create. If they are
664    the same, Zope will return a HTTP response that "nothing has
665    changed, feel free to use your current copy". If they differ, it
666    will return the new page.
667
668    So, for example, if Joel re-visits http://news-items/project-a
669    when he is logged out, his browser will hand Zope the ETag it has
670    from his last visit, joelburton-2006/12/25-en.  Zope looks at the
671    logged in user (now Anonymous) and creates a new ETag::
672
673      ETag: anonymous-2006/12/25-en
674
675    (requested by Anonymous, content last modified on Christmas,
676    prefer it in English). Since this is different than the ETag that
677    the proxy cache submitted, Zope will return the content itself,
678    since anonymous users might need a different page (without Joel's
679    name, for instance, or with different things showing because of
680    security).
681
682    Squid cannot handle requests with ETags, since it has no way of
683    knowing who is logged in, when content was created, and so on, so
684    all of these requests get routed around squid. 
685
686  The "ETag Components" choice allows you to select what things should
687  make up the ETag; as you choose things here, if any of these things
688  changes, it would cause the ETag to change, and cause the page to be
689  recalculated.
690
691  The default settings are sane but cautious: it causes a
692  re-examination if there are changes to the user who requested the
693  page, the current skinpath (i.e.,, Plone Default, Plone Tableless, or
694  a custom skinpath), whether they want gzipped content or not,
695  and the time of the last catalog change.
696
697  The list is an interesting idea. If you edit a news item, of course,
698  we'd want CacheFu to stop returning the old copy of that news item
699  view.  However, if you edit the title of the folder that news item
700  was in, we'd *also* want CacheFu to stop returning the old copy of
701  that news item view, since the old title of the parent folder would
702  appear in the navigation portlet, breadcrumbs, etc.
703
704  By having the date/time of the last catalog change factor into the
705  ETag, *any* change to *any* object will cause CacheFu to
706  re-create the content pages. This guarantees fresh navigation,
707  but at the expense of re-creating things where staleness might have
708  never been an issue, or where it might have been acceptable.
709
710  This ETag setting is just for logged-in users; for anonymous users,
711  remember, the page is cached in the proxy for an hour regardless of
712  ETags, and, as such, any change to the site won't cause everything
713  to be unusable from cache.
714
715  If you don't care about this, and desire more performance, you could
716  opt to change the "Time of last catalog change" to "Context
717  modification time". This would mean that editing anything won't
718  invalidate all ETags, but it does mean that an old title for a
719  sibling might appear in the navigation tree or breadcrumbs, or such.
720  This can significantly speed up performance, and may be worth
721  considering.
722
723  In addition to the checkbox ETag choices, you also can indicate
724  which request values should be factored into the ETag. The default is
725  month, year, orig_query. This is used for the calendar portlet--you
726  might have changed nothing on the site since this page was requested
727  a while ago *but* this request is for a user who has clicked the
728  next-month button on the calendar, and, as such, needs a different
729  response: the same piece of content, but with the calendar portlet
730  showing the next month.
731
732  If you add other form variables to your view templates and changes
733  to these should cause the page to be cached differently, you should
734  add them here.
735
736  Note the difference between the "Cache Preventing Request Values",
737  above (which held "portal_status_message") and this. The
738  cache-preventing-values piece says that *if this value exists, don't
739  match the rule* (and therefore, don't send out the caching headers,
740  etc., for this rule). The "ETag request values" field says *you can
741  cache it if this value exists, but consider it a different request*.
742 
743  "ETag Timeout" is a failsafe for ETags. This is the number of
744  seconds that an ETag should ever last. At 3600 (the default here),
745  it means that *even if* the ETag comparison suggests nothing has
746  changed, that Zope should generate a new page anyway. It's good to
747  have this--this way, if you forget to have your caching predicated
748  on a certain value, you *still* won't hold onto stale content views
749  for more than one hour.
750
751  "ETag Expression" allows you calculate anything as an additional
752  ETag value.
753
754  "Purge Expression" is a script that can handle the purging in Squid
755  of content views once changed. You shouldn't have to edit this.
756
757Containers
758
759  This rule is used for folderish content types (Folder and Large
760  Plone Folder). It is similar to the Content rule.
761
762  The difference is that, for anonymous users, the Content rule caches
763  the view of the content object until the object changes, whereas,
764  that would provide too much stale content for views of folderish
765  objects. The view of a folder traditionally is a list of the child
766  objects, so when a folder gets a new document added to it, or has
767  one of its child documents edited, the view of the entire folder
768  needs to be changed.
769
770  It's difficult to decide if any child object was changed; instead,
771  CacheFu relies on the quick (but much more general) rule of: has
772  any object in the entire catalog been changed? If so, the view for
773  a Folderish object must be regenerated.
774
775  Therefore, these are never cached in Squid or Apache (it would be
776  difficult to purge every possible view of every folderish content
777  item on every catalog change!) and are cached in Zope, using the
778  same ETag strategy as for the Content rule, above. Essentially,
779  both anonymous and logged-in users who view container views are
780  treated the same as logged-in users viewing content with the
781  Content rule.
782
783Templates
784
785  This rule is for "templates"--skin objects like Page Templates
786  that are not presenting a piece of content, and are not forms.
787  A good example is the "accessibility-info" template that comes with
788  Plone; this isn't content, is not a form, but is a page that
789  could be cached until it changes.
790
791  The "templates" field is a list of those templates that match
792  this rule. As you add new templates that could be matched by the
793  rule, you can list them here.
794
795  These are cached with ETags, using the same strategy as for Content
796  and Containers rules, above.
797
798  Similar to the Container rule strategy, the cache is cleared for
799  these every time the catalog changes. Almost all template rely
800  on the main template, which relies on a dozen other templates, and
801  it would be very difficult to track all of these dependencies.
802  Therefore, any change to anything in Zope might affect what these
803  template should show, and, as such, clears them.
804
805  This is safe and conservative. Some sites may decide that it is
806  acceptable, for anonymous users, to cache these Templates in a proxy
807  server, so that they are cached for an hour (or 24 hours, or more).
808  Changes to the template itself, or to the `main_template` or other
809  template won't appear, but these sort of changes might be very rare
810  on a production site, and, if they happened, the sysadmin could
811  restart the proxy server to clear it's entire cache.
812
813.. tip:: Why Not Forms?
814
815  So, why aren't forms cachable with the Template rule?
816
817  Forms are use in Plone both to show the form, and also to
818  re-present the form with validation errors; if the form was
819  cached and used from cache, it might have validation errors
820  and already-entered data from a previous user.
821
822  FIXME: geoffd, couldn't this be fixed by adding form.submitted
823  to the 'Cache preventing request values' box? Or are there
824  other reasons why forms shouldn't be cached? [GD: yes, probably, but
825  I don't think it would be a huge win]
826
827XXXX END OF WRITTEN PART
828
829- More likely to use Apache than Squid, or to use nothing at all
830
831  - But everything should "work" w/o Squid, even if things are cache-in-mem rather than cache-in-squid when they could be
832
833- Should know to associate w/HTTP Cache for fine-to-cache full pages (ie, homepage if w/o personalization & portlets)
834
835- Cloned content types that are non-folderish should be added to content rules
836
837- New views for content (ie, news_item_short) that aren't on the display menu choices should be added to content tab
838
839- If add portlets that use form vars (ie, show-more-news-in-portlet or show-less-news-in-portlet), add this formvar to "etag request item" in all places
840
841- Cloned folderish types should get added to the containers tab
842
843- New views for folderish things that aren't on display menu choice should be added to containers tab
844
845- New templates that aren't contentish should be added to "templates" as long as it doesn't depend on things like clock
846
847  - if template uses formvars, add them to cache_preventing_Req_items, unless they're commonly-shared (worse case is that we
848    cache too many choices)
849
850- Nothing to know about for CSS/JS
851
852- If we clone new File/Image types, add to file/image
853
854- Know when to clear page cache [XXX: when is that? GD: for debugging]
855
856- *Might* be helpful for them to understand the header-settings, but only the most basic (ie, cache-for-1h-not-1d, etc.)
857
858  - XXX: should we ship additional header settings (ie, ship with "cache-in-mem-for-1h" v "cache-in-member-for-1d" (both of which could still be cleared, of course, but would have diff max cache lengths)
859
860- RAMCaches still work exactly the same, so you can still do things like cache production of news-item-portlet-search
861
862  - Nothing here to clear those RAM caches in advance, or in any smart way
863
864- RelDB caches still work the same
865
866  - Nothing here to clear those reldb caches in advance
867
868
869Intermediate Developers
870=======================
871
872- [These are people who are building Archetypes, building web apps, but not neccessarily hard-core-geeks]
873
874- FIXME
875
876Advanced Developers
877===================
878
879- [These are people who are seriously customizing Plone, and will learn more knobs to get more power]
880
881- FIXME
882
883System Admins
884=============
885
886- [People who administer the Squid/Apache stuff, but aren't necc Zope/Plone people]
887
888- FIXME
889
890-----------------
891Special Audiences
892-----------------
893
894People may fit into more than one of these, in addition to above audiences.
895
896
897People who store uesrs in LDAP / Rel DB
898=======================================
899
900- Default caching is too aggressive to cover this case
901
902- Should check "user roles" everywhere that "user id" is checked in ETags
903
904  - Covers case of "joel was manager but changed in LDAP to make him just member"
905 
906  - Since that won't change catalog, and therefore won't work w/existing etag choices
907
908People who don't store content in ZODB
909======================================
910
911- (ie, storing content on filesytem or in relational database)
912
913- If catalog doesn't change on content change, many clear-cache features won't work
914
915  - Default caching will be too aggressive
916
917  - [FIXME: Is there a built-in fix for this? They could just not add those fs- or reldb-stored content types to "content" tab, right? This miss anything significant?]
918
919People Who Want to Learn to Use Squid
920=====================================
921
922- FIXME: What do they need to know to do this?
923
924LDAP/RelDB storage of users
925===========================
926
927- Cachefu can act on user roles or on user, and not know that user perms have changed
Note: See TracBrowser for help on using the repository browser.