Skip to content

Commit

Permalink
Changed default config to use-cache: no.
Browse files Browse the repository at this point in the history
Rationale:  gitit is pretty fast without any caching,
and this is simplest for most needs.  Users who need
caching can enable it explicitly, and they will then
know about possible side-effects (e.g. the need to
manually expire the cache after updating via the VCS).

Updated caching documentation.
  • Loading branch information
jgm committed Aug 15, 2009
1 parent 06d4b45 commit f22d5c4
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 38 deletions.
2 changes: 2 additions & 0 deletions Network/Gitit/Layout.hs
Expand Up @@ -62,6 +62,7 @@ formattedPage layout htmlContents = do
-- | Given a compiled string template, returns a page renderer.
defaultRenderPage :: T.StringTemplate String -> PageLayout -> Html -> Handler
defaultRenderPage templ layout htmlContents = do
cfg <- getConfig
let rev = pgRevision layout
let page = pgPageName layout
base' <- getWikiBase
Expand Down Expand Up @@ -93,6 +94,7 @@ defaultRenderPage templ layout htmlContents = do
(renderHtmlFragment $ exportBox base' page rev) .
T.setAttribute "tabs" (renderHtmlFragment tabs) .
T.setAttribute "messages" (pgMessages layout) .
T.setAttribute "usecache" (useCache cfg) .
T.setAttribute "content" (renderHtmlFragment htmlContents) $
templ
ok $ setContentType "text/html" $ toResponse filledTemp
Expand Down
78 changes: 41 additions & 37 deletions README.markdown
Expand Up @@ -12,12 +12,12 @@ formats, including LaTeX, RTF, OpenOffice ODT, and MediaWiki markup.
Gitit can be configured to display TeX math (using [jsMath][]) and
highlighted source code (using [highlighting-kate][]).

[git]: http://git.or.cz
[git]: http://git.or.cz
[darcs]: http://darcs.net
[pandoc]: http://johnmacfarlane.net/pandoc
[Happstack]: http://happstack.com
[jsMath]: http://www.math.union.edu/~dpvc/jsMath/
[highlighting-kate]: http://johnmacfarlane.net/highlighting-kate/
[highlighting-kate]: http://johnmacfarlane.net/highlighting-kate/

Getting started
===============
Expand Down Expand Up @@ -185,40 +185,6 @@ title
: By default the displayed page title is the page name. This metadata element
overrides that default.

Caching
-------

By default, gitit caches rendered pages and highlighted source
code files in the `cache` directory. (This can be changed by modifying
the `use-cache` and `cache-dir` options in the configuration file; see
below for information about configuring gitit.)

Cached pages are updated when pages are modified using the web
interface. They are not updated when pages are modified directly
through git or darcs. However, the cache can be refreshed manually
by pressing Ctrl-R when viewing a page, or by sending an HTTP
GET or POST request to `/_expire/path/to/page`, where `path/to/page` is
the name of the page to be expired.

Users who frequently update pages using git or darcs may wish
to set `use-cache` to `no`, or alternatively to add a hook to
the repository that makes the appropriate HTTP request to expire
pages when they are updated. To facilitate such hooks, the gitit
cabal package includes an executable `expireGititCache`. Assuming
you are running gitit at port 5001 on localhost, and the
environment variable `CHANGED_FILES` contains a list of the files
that have changed, you can expire their cached versions using

expireGititCache http://localhost:5001 $CHANGED_FILES

Or you can specify the files directly:

expireGititCache http://localhost:5001 "Front Page.page" foo/bar/baz.c

This program will return a success status (0) if the page has been
successfully expired (or if it was never cached in the first place),
and a failure status (> 0) otherwise.

Configuring gitit
=================

Expand Down Expand Up @@ -347,6 +313,44 @@ with the wiki using git command line tools:
If you now look at the Front Page on the wiki, you should see your changes
reflected there. Note that the pages all have the extension `.page`.

Caching
=======

By default, gitit does not cache content. If your wiki receives a lot of
traffic or contains pages that are slow to render, you may want to activate
caching. To do this, set the configuration option `use-cache` to `yes`.
By default, rendered pages and highlighted source files will be cached
in the `cache` directory. (Another directory can be specified by setting
the `cache-dir` configuration option.)

Cached pages are updated when pages are modified using the web
interface. They are not updated when pages are modified directly through
git or darcs. However, the cache can be refreshed manually by pressing
Ctrl-R when viewing a page, or by sending an HTTP GET or POST request to
`/_expire/path/to/page`, where `path/to/page` is the name of the page to
be expired.

Users who frequently update pages using git or darcs may wish to add a
hook to the repository that makes the appropriate HTTP request to expire
pages when they are updated. To facilitate such hooks, the gitit cabal
package includes an executable `expireGititCache`. Assuming you are
running gitit at port 5001 on localhost, and the environment variable
`CHANGED_FILES` contains a list of the files that have changed, you can
expire their cached versions using

expireGititCache http://localhost:5001 $CHANGED_FILES

Or you can specify the files directly:

expireGititCache http://localhost:5001 "Front Page.page" foo/bar/baz.c

This program will return a success status (0) if the page has been
successfully expired (or if it was never cached in the first place),
and a failure status (> 0) otherwise.

The cache is persistent through restarts of gitit. To expire all cached
pages, simply remove the `cache` directory.

Using gitit with apache
=======================

Expand Down Expand Up @@ -464,7 +468,7 @@ Acknowledgements
A number of people have contributed patches:

- Gwern Branwen helped to optimize gitit and wrote the
InterwikiPlugin.
InterwikiPlugin. He also helped with the Feed module.
- Simon Michael contributed the patch adding RST support.
- Henry Laxen added support for password resets and helped with
the apache proxy instructions.
Expand Down
2 changes: 1 addition & 1 deletion data/default.conf
Expand Up @@ -100,7 +100,7 @@ plugins:
# plugins: plugins/DotPlugin
# plugins: Gitit.Plugin.InterwikiLinks

use-cache: yes
use-cache: no
# specifies whether to cache rendered pages

cache-dir: cache
Expand Down
2 changes: 2 additions & 0 deletions data/templates/expire.st
@@ -1,3 +1,4 @@
$if(usecache)$
<script type="text/javascript" src="$base$/_static/js/jquery.hotkeys-0.7.9.min.js"></script>
<script type="text/javascript">
/* <![CDATA[ */
Expand All @@ -7,3 +8,4 @@
});
/* ]]> */
</script>
$endif$

0 comments on commit f22d5c4

Please sign in to comment.