diff options
author | Lukas Fleischer <cgit@cryptocrack.de> | 2014-02-21 04:59:22 (JST) |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2014-02-21 09:19:45 (JST) |
commit | 6ceba453a27ead382d0116d95bdeb6b6be1149e2 (patch) | |
tree | 3a4daf5a4d2fd1c0d158f41b4ea5350596fc25a2 | |
parent | 8033dc01f4ae1551c21769f580caa723fb176d9c (diff) | |
download | cgit-6ceba453a27ead382d0116d95bdeb6b6be1149e2.zip cgit-6ceba453a27ead382d0116d95bdeb6b6be1149e2.tar.gz |
Skip cache slot when time-to-live is zero
If time-to-live is set to zero, we don't need to regenerate the cache
slots on every request. Instead, just skip the caching process and
immediately provide the dynamically generated version of the page.
Setting time-to-live to zero is useful when you want to disable caching
for certain pages.
Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
-rw-r--r-- | cache.c | 2 | ||||
-rw-r--r-- | cgitrc.5.txt | 22 |
2 files changed, 15 insertions, 9 deletions
@@ -343,7 +343,7 @@ int cache_process(int size, const char *path, const char *key, int ttl, | |||
343 | int result; | 343 | int result; |
344 | 344 | ||
345 | /* If the cache is disabled, just generate the content */ | 345 | /* If the cache is disabled, just generate the content */ |
346 | if (size <= 0) { | 346 | if (size <= 0 || ttl == 0) { |
347 | fn(); | 347 | fn(); |
348 | return 0; | 348 | return 0; |
349 | } | 349 | } |
diff --git a/cgitrc.5.txt b/cgitrc.5.txt index a437fc4..7158c10 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt | |||
@@ -61,37 +61,43 @@ cache-root:: | |||
61 | cache-static-ttl:: | 61 | cache-static-ttl:: |
62 | Number which specifies the time-to-live, in minutes, for the cached | 62 | Number which specifies the time-to-live, in minutes, for the cached |
63 | version of repository pages accessed with a fixed SHA1. Negative | 63 | version of repository pages accessed with a fixed SHA1. Negative |
64 | values have infinite ttl. Default value: -1". | 64 | values have infinite ttl, zero means that the cache is disabled for |
65 | this type of pages. Default value: -1". | ||
65 | 66 | ||
66 | cache-dynamic-ttl:: | 67 | cache-dynamic-ttl:: |
67 | Number which specifies the time-to-live, in minutes, for the cached | 68 | Number which specifies the time-to-live, in minutes, for the cached |
68 | version of repository pages accessed without a fixed SHA1. Negative | 69 | version of repository pages accessed without a fixed SHA1. Negative |
69 | values have infinite ttl. Default value: "5". | 70 | values have infinite ttl, zero means that the cache is disabled for this |
71 | type of pages. Default value: "5". | ||
70 | 72 | ||
71 | cache-repo-ttl:: | 73 | cache-repo-ttl:: |
72 | Number which specifies the time-to-live, in minutes, for the cached | 74 | Number which specifies the time-to-live, in minutes, for the cached |
73 | version of the repository summary page. Negative values have infinite | 75 | version of the repository summary page. Negative values have infinite |
74 | ttl. Default value: "5". | 76 | ttl, zero means that the cache is disabled for this type of pages. |
77 | Default value: "5". | ||
75 | 78 | ||
76 | cache-root-ttl:: | 79 | cache-root-ttl:: |
77 | Number which specifies the time-to-live, in minutes, for the cached | 80 | Number which specifies the time-to-live, in minutes, for the cached |
78 | version of the repository index page. Negative values have infinite | 81 | version of the repository index page. Negative values have infinite |
79 | ttl. Default value: "5". | 82 | ttl, zero means that the cache is disabled for this type of pages. |
83 | Default value: "5". | ||
80 | 84 | ||
81 | cache-scanrc-ttl:: | 85 | cache-scanrc-ttl:: |
82 | Number which specifies the time-to-live, in minutes, for the result | 86 | Number which specifies the time-to-live, in minutes, for the result |
83 | of scanning a path for git repositories. Negative values have infinite | 87 | of scanning a path for git repositories. Negative values have infinite |
84 | ttl. Default value: "15". | 88 | ttl, zero means that the cache is disable for this type of pages. |
89 | Default value: "15". | ||
85 | 90 | ||
86 | cache-about-ttl:: | 91 | cache-about-ttl:: |
87 | Number which specifies the time-to-live, in minutes, for the cached | 92 | Number which specifies the time-to-live, in minutes, for the cached |
88 | version of the repository about page. Negative values have infinite | 93 | version of the repository about page. Negative values have infinite |
89 | ttl. Default value: "15". | 94 | ttl, zero means that the cache is disable for this type of pages. |
95 | Default value: "15". | ||
90 | 96 | ||
91 | cache-snapshot-ttl:: | 97 | cache-snapshot-ttl:: |
92 | Number which specifies the time-to-live, in minutes, for the cached | 98 | Number which specifies the time-to-live, in minutes, for the cached |
93 | version of snapshots. Negative values have infinite ttl. Default | 99 | version of snapshots. Negative values have infinite ttl, zero means |
94 | value: "5". | 100 | that the cache is disable for this type of pages. Default value: "5". |
95 | 101 | ||
96 | cache-size:: | 102 | cache-size:: |
97 | The maximum number of entries in the cgit cache. Default value: "0" | 103 | The maximum number of entries in the cgit cache. Default value: "0" |