Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 6fd2a676c3
Fetching contributors…

Cannot retrieve contributors at this time

file 90 lines (84 sloc) 6.502 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90

<!DOCTYPE html>
    <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
    <title>Thinner -- Version 0.1.4</title>
    <link rel="stylesheet" type="text/css" href="documentation/css/styles.css" />
    <link rel="stylesheet" type="text/css" href="documentation/css/dawn.css" />
    <a href="" class="propublica">&nbsp;</a>
    <h1>Thinner &ndash; Version 0.1.4</h1>
    <p><a href="">Thinner</a> is a utility
      for purging urls from a Varnish server.</p>
    <p>When you are deploying code changes to a server under load, the uncached
       load can quickly bring down your backend server even with Varnish's grace
       mode. Often, allowing stale caches to stick around for a while saves
       both server performance and sanity.</p>
    <p>Thinner gives you fine-grained control over wildcard purging, and rolls
      purges out slowly. Your users will see stale pages from the previous deploy
      until Thinner has finished invalidating the stale cache at a rate that you set.
      If you have a bunch of pages you need to invalidate en masse and at infrequent
      intervals (e.g. deploys, timed remote api updates), but don't want to
      risk overloading your server, Thinner is for you.</p>
    <p>All that being said, Thinner isn't really a solution for observing
      model changes and purging associated urls. If you have a highly dynamic
      application, it's worlds better to handle purging via a
      <a href="">job server</a>
      outside of the request-response flow.</p>
    <p><a href="doc/index.html">API docs</a> | <a href="">Issue Tracker</a></p>
    <p>Thinner is available via rubygems:
    <pre>gem install thinner</pre>
    <p>Thinner has both a library and command-line interface. To use it as a gem
      you'll first have to configure how it works by calling <strong>Thinner.configure</strong>.
      Here's a quick rundown of all of the options available:</p>
      <pre class="dawn"><span class="Support">Thinner</span><span class="PunctuationSeparator">.</span><span class="Entity">configure</span> <span class="Keyword">do </span><span class="PunctuationSeparator">|</span><span class="Variable">config</span><span class="PunctuationSeparator">|</span>
<span class="Comment"> <span class="Comment">#</span> Number of urls to purge at one time. These purge requests are fired in quick</span>
<span class="Comment"> <span class="Comment">#</span> succession. Thinner is perfectly capable of killing a Varnish server, by</span>
<span class="Comment"> <span class="Comment">#</span> overloading the worker thread, so be really conservative with this option.</span>
  config<span class="PunctuationSeparator">.</span><span class="Entity">batch_length</span> <span class="Keyword">=</span> <span class="Constant">10</span>

<span class="Comment"> <span class="Comment">#</span> The amount of time to sleep between purges in seconds.</span>
  config<span class="PunctuationSeparator">.</span><span class="Entity">sleep_time</span> <span class="Keyword">=</span> <span class="Constant">1</span>

<span class="Comment"> <span class="Comment">#</span> The server address and management port. See:</span>
<span class="Comment"> <span class="Comment">#</span></span>
<span class="Comment"> <span class="Comment">#</span> for details.</span>
  config<span class="PunctuationSeparator">.</span><span class="Entity">server</span> <span class="Keyword">=</span> &quot;;

<span class="Comment"> <span class="Comment">#</span> By default, every time you call Thinner.purge! thinner spins off a new</span>
<span class="Comment"> <span class="Comment">#</span> instance of Thinner::Client and terminates any old instances that are</span>
<span class="Comment"> <span class="Comment">#</span> running. If you want to have overlapping instances set this to true.</span>
<span class="Comment"> <span class="Comment">#</span> It's not recommended to have multiple Thinner::Client's running at the</span>
<span class="Comment"> <span class="Comment">#</span> same time.</span>
  config<span class="PunctuationSeparator">.</span><span class="Entity">no_kill</span> <span class="Keyword">=</span> <span class="Constant">false</span>

<span class="Comment"> <span class="Comment">#</span> The log file (either a string or file object) to log the current batch to.</span>
<span class="Comment"> <span class="Comment">#</span> Defaults to STDOUT</span>
  config<span class="PunctuationSeparator">.</span><span class="Entity">log_file</span> <span class="Keyword">=</span> <span class="Variable">STDOUT</span>
<span class="Keyword">end</span>
    <p>Once you have the configuration in place call <strong>purge!</strong> with
      an array of urls:</p>
      <pre class="dawn"><span class="Comment"><span class="Comment">#</span> The urls in this array are purged in order, so you'll want to structure it</span>
<span class="Comment"><span class="Comment">#</span> according to usage.</span>
arr <span class="Keyword">&lt;&lt;</span> [&quot;/some_route&quot;<span class="PunctuationSeparator">,</span> &quot;/some_route/with.*&quot;<span class="PunctuationSeparator">,</span> &quot;/&quot;]

<span class="Support">Thinner</span><span class="PunctuationSeparator">.</span><span class="Entity">purge!</span> arr
    <p>Thinner will then fork a background process and purge the urls. You can
      check the progress of the purge by tailing the log file or with:</p>
      <pre>varnishlog | grep purge</pre>
    <p>If ruby's not your cup of tea, Thinner also has a command line interface.
      Once you've installed the gem run <strong>thinner -h</strong> to see the
      available options.</p>
    <p>The command line interface accepts a newline separated list of urls via
      stdin by setting the <strong>-e</strong> flag. So you'll be able to use
      the command like so:</p>
      <pre>cat urls_to_purge.txt | bin/thinner -e</pre>
    <h2>Change Log</h2>
    <p>Force process to exit on signals and fixed gem warning.</p>
    <p>Fixed bug in command line argument parsing.</p>
    <p>Initial release.</p>
Something went wrong with that request. Please try again.