{% extends "admin/layout.html" %}
{% block title %}{{ _("Cache Options") }}{% endblock %}
{% block contents %}
  <h1>{{ _("Cache Options") }}</h1>
  {% call form() %}
    <p>{% trans %}
      Zine comes with a cache system that allows you to survive a sudden
      storm of visitors. The caching system has different backends you can
      choose from and also different settings that you should set depending on
      the type of server you have and the number of visitors.
    {% endtrans %}</p>
    <p>{% trans %}
      Keep in mind that if caching is enabled templates will be cached too and
      as a result of that, they are not reloaded. If you are trying to develop 
      plugins it might be a good idea to disable all caching.
    {% endtrans %}</p>
    <script type="text/javascript">
      $(function() {
        $('select').change(function() {
          var activeItem = $(this).val();
          $('div.optionbox').each(function() {
            $(this).is('#' + activeItem + '-options')
              ? $(this).show() : $(this).hide();
          });
        }).change();
      });
    </script>
    <h2>{{ _("Cache System") }}</h2>
    <p>{{ _("Currently Zine supports three caching systems:") }}</p>
    <ul>
      <li>{% trans %}<strong>Simple Cache</strong>: The simple cache is a very
          basic memory cache inside the server process. This cache works only
          if you have a persistent environment. Roughly speaking this cache
          works better the higher the number of threads in a process and the
          lower the number or processes. If you have the chance to use a
          memcached you should not use the simple cache.{% endtrans %}</li>
      <li>{% trans %}<strong>memcached</strong>: This cache system uses one
          or multiple remote memcached servers for storing the cache
          information. It requires at least one running memcached daemon. This
          is useful for high traffic sites.{% endtrans %}</li>
      <li>{% trans %}<strong>Filesystem</strong>: This cache system stores the
          cache information on the filesystem. If IO is a problem for you,
          you should not use this cache. However for most of the cases the 
          filesystem it should be fast enough.{% endtrans %}</li>
    </ul>
    <p>{% trans %}Per default no cache system is active.{% endtrans %}</p>
    <p>{{ form.cache_system() }}</p>
    <div class="optionbox" id="memcached-options">
      <h2>{{ _("Memcached Options") }}</h2>
      <p>{% trans %}
        In order to use the memcached system you have to provide the address
        of at least one machine running memcached.  For further details have
        a look at <a href="http://www.danga.com/memcached/">the memcached
        webpage</a>.  Separate multiple addresses with commas.  This also
        requires either the <a href="http://gijsbert.org/cmemcache/"
        >cmemcache</a> or <a href="ftp://ftp.tummy.com/pub/python-memcached/"
        >python-memcached</a> module.
      {% endtrans %}</p>
      <p>{% trans %}
        If you for example have a memcached running on localhost (127.0.0.1)
        port 11211 you would have to enter <code>127.0.0.1:11211</code> into
        the following text field.
      {% endtrans %}</p>
      <p>{{ form.memcached_servers(size=60) }}</p>
    </div>
    <div class="optionbox" id="filesystem-options">
      <h2>{{ _("Filesystem Options") }}</h2>
      <p>{% trans %}
        When using the filesystem cache you can control where Zine puts
        all the cache data.  This path is relative to your Zine instance
        folder and will be created automatically by Zine.  Keep in mind
        that if you change that path and old cache data is left in the old
        folder, Zine won't clean up the data left for you.
      {% endtrans %}</p>
      <p>{% trans %}
        One thing you have to keep in mind is that the cache path <em>must</em>
        be a directory that only Zine uses for file management. The
        Zine code cleans up there from time to time and it could delete
        files that are otherwise not tracked by Zine. This is especially
        the case if you try to cache into <code>/tmp</code> or a similar
        folder that all kinds of applications use for storing temporary files.
      {% endtrans %}</p>
      <p>{{ form.filesystem_cache_path(size=40) }}</p>
    </div>
    <h2>{{ _("General Cache Settings") }}</h2>
    <p>{% trans %}
      The following configuration values are cache system-independent. You
      can use them to fine-tune the caching. The timeout is the number of
      seconds an item is cached per default. Some items have different cache
      timeouts though. If “eager caching” is enabled the cache system will
      cache a lot more but it will have visible side-effects. For example
      new blog posts won't appear on the index or in the feed for up to the
      default timeout.
    {% endtrans %}</p>
    <dl>
      {{ form.cache_timeout.as_dd() }}
      {{ form.enable_eager_caching.as_dd() }}
    </dl>
    <div class="actions">
      <input type="submit" value="{{ _('Save') }}">
      <input type="submit" name="clear_cache" value="{{ _('Clear Cache') }}">
    </div>
  {% endcall %}
{% endblock %}
