summaryrefslogtreecommitdiffhomepage
path: root/src/http/ngx_http_cache.h (unfollow)
AgeCommit message (Collapse)AuthorFilesLines
2020-09-09Cache: keep c->body_start when Vary changes (ticket #2029).Sergey Kandaurov1-0/+1
If the variant hash doesn't match one we used as a secondary cache key, we switch back to the original key. In this case, c->body_start was kept updated from an existing cache node overwriting the new response value. After file cache update, it led to discrepancy between a cache node and cache file seen as critical errors "file cache .. has too long header".
2020-06-22Cache: introduced min_free cache clearing.Maxim Dounin1-0/+1
Clearing cache based on free space left on a file system is expected to allow better disk utilization in some cases, notably when disk space might be also used for something other than nginx cache (including nginx own temporary files) and while loading cache (when cache size might be inaccurate for a while, effectively disabling max_size cache clearing). Based on a patch by Adam Bambuch.
2017-08-04Cache: reset c->body_start when reading a variant on Vary mismatch.Sergey Kandaurov1-0/+1
Previously, a variant not present in shared memory and stored on disk using a secondary key was read using c->body_start from a variant stored with a main key. This could result in critical errors "cache file .. has too long header".
2017-02-10Cache: increased cache header Vary and ETag lengths to 128.Maxim Dounin1-3/+3
This allows to store larger ETag values for proxy_cache_revalidate, including ones generated as SHA256, and cache responses with longer Vary (ticket #826). In particular, this fixes caching of Amazon S3 responses with CORS enabled, which now use "Vary: Origin, Access-Control-Request-Headers, Access-Control-Request-Method". Cache version bumped accordingly.
2017-02-10Upstream: proxy_cache_background_update and friends.Roman Arutyunyan1-0/+1
The directives enable cache updates in subrequests.
2016-12-22Cache: support for stale-while-revalidate and stale-if-error.Roman Arutyunyan1-1/+8
Previously, there was no way to enable the proxy_cache_use_stale behavior by reading the backend response. Now, stale-while-revalidate and stale-if-error Cache-Control extensions (RFC 5861) are supported. They specify, how long a stale response can be used when a cache entry is being updated, or in case of an error.
2016-11-03Cache: prefix-based temporary files.Maxim Dounin1-1/+3
On Linux, the rename syscall can be slow due to a global file system lock, acquired for the entire rename operation, unless both old and new files are in the same directory. To address this temporary files are now created in the same directory as the expected resulting cache file when using the "use_temp_path=off" parameter. This change mostly reverts 99639bfdfa2a and 3281de8142f5, restoring the behaviour as of a9138c35120d (with minor changes).
2016-10-10Modules compatibility: compatibility with NGX_THREADS.Maxim Dounin1-1/+1
With this change it is now possible to load modules compiled without the "--with-threads" configure option into nginx binary compiled with it, and vice versa (if a module does not use thread-specific functions), assuming both use the "--with-compat" option.
2016-10-05Cache: cache manager limits.Dmitry Volyntsev1-0/+4
The new parameters "manager_files", "manager_sleep" and "manager_threshold" were added to proxy_cache_path and friends. Note that ngx_path_manager_pt was changed to return ngx_msec_t instead of time_t (API change).
2016-09-29Modules compatibility: cache purge fields.Maxim Dounin1-1/+4
2016-03-18Cache: added watermark to reduce IO load when keys_zone is full.Dmitry Volyntsev1-0/+2
When a keys_zone is full then each next request to the cache is penalized. That is, the cache has to evict older files to get a slot from the keys_zone synchronously. The patch introduces new behavior in this scenario. Manager will try to maintain available free slots in the keys_zone by cleaning old files in the background.
2016-03-18Cache: report error if slab allocator fails during cache loading.Dmitry Volyntsev1-0/+2
2015-04-01Cache: added support for reading of the header in thread pools.Valentin Bartenev1-0/+4
2015-02-02Cache: added temp_path to file cache.Roman Arutyunyan1-3/+1
If use_temp_path is set to off, a subdirectory "temp" is created in the cache directory. It's used instead of proxy_temp_path and friends for caching upstream response.
2014-12-26Upstream: use_temp_path parameter of proxy_cache_path and friends.Valentin Bartenev1-0/+3
When set to "off", temporary files for cacheable responses will be stored inside cache directory.
2014-12-26Cache: update variant while setting header.Valentin Bartenev1-1/+1
Some parts of code related to handling variants of a resource moved into a separate function that is called earlier. This allows to use cache file name as a prefix for temporary file in the following patch.
2014-11-18Cache: proxy_cache_lock_age and friends.Roman Arutyunyan1-0/+3
Once this age is reached, the cache lock is discarded and another request can acquire the lock. Requests which failed to acquire the lock are not allowed to cache the response.
2014-10-27Cache: multiple variants of a resource now can be stored.Maxim Dounin1-0/+2
If a variant stored can't be used to respond to a request, the variant hash is used as a secondary key. Additionally, if we previously switched to a secondary key, while storing a response to cache we check if the variant hash still apply. If not, we switch back to the original key, to handle cases when Vary changes.
2014-10-27Cache: c->reading flag introduced.Maxim Dounin1-0/+1
It replaces c->buf in checks in ngx_http_file_cache_open(), making it possible to reopen the file without clearing c->buf. No functional changes.
2014-10-27Cache: hash of Vary headers now stored in cache.Maxim Dounin1-1/+7
To cache responses with Vary, we now calculate hash of headers listed in Vary, and return the response from cache only if new request headers match. As of now, only one variant of the same resource can be stored in cache.
2014-06-26Cache: ETag now saved into cache header.Maxim Dounin1-1/+6
2014-06-26Cache: version in cache files.Maxim Dounin1-0/+3
This allows to change the structure of cache files without spamming logs with false alerts.
2013-11-18Upstream: cache revalidation with conditional requests.Maxim Dounin1-2/+4
The following new directives are introduced: proxy_cache_revalidate, fastcgi_cache_revalidate, scgi_cache_revalidate, uwsgi_cache_revalidate. Default is off. When set to on, they enable cache revalidation using conditional requests with If-Modified-Since for expired cache items. As of now, no attempts are made to merge headers given in a 304 response during cache revalidation with headers previously stored in a cache item. Headers in a 304 response are only used to calculate new validity time of a cache item.
2012-01-18Copyright updated.Maxim Konovalov1-0/+1
2011-12-26Cache locks initial implementation.Maxim Dounin1-0/+8
New directives: proxy_cache_lock on/off, proxy_cache_lock_timeout. With proxy_cache_lock set to on, only one request will be allowed to go to upstream for a particular cache item. Others will wait for a response to appear in cache (or cache lock released) up to proxy_cache_lock_timeout. Waiting requests will recheck if they have cached response ready (or are allowed to run) every 500ms. Note: we intentionally don't intercept NGX_DECLINED possibly returned by ngx_http_file_cache_read(). This needs more work (possibly safe, but needs further investigation). Anyway, it's exceptional situation. Note: probably there should be a way to disable caching of responses if there is already one request fetching resource to cache (without waiting at all). Two possible ways include another cache lock option ("no_cache") or using proxy_no_cache with some supplied variable. Note: probably there should be a way to lock updating requests as well. For now "proxy_cache_use_stale updating" is available.
2011-07-29loader_files, loader_sleep, and loader_thresholdIgor Sysoev1-1/+4
2011-04-22Use more precise stat.st_blocks to account cache size on UnixIgor Sysoev1-1/+2
instead of file length rounded to a file system block size. There is no similar way on Windows, so rounding to a cache->bsize is kept.
2010-09-02fix race condition if during reconfiguration two cache managers tryIgor Sysoev1-1/+2
to delete old inactive entries: one of them removes a entry just locked by other manager from the queue and the rbtree as long inactive entry, causes the latter manager to segfault leaving cache mutex locked, the bug has been introduced in r3727
2010-07-28several changes in cache cleanup handling:Igor Sysoev1-1/+2
*) now ngx_http_file_cache_cleanup() uses ngx_http_file_cache_free() *) ngx_http_file_cache_free() interface has been changed to accept r->cache ngx_http_file_cache_cleanup() must use r->cache, but not r, because there can be several r->cache's during request processing, r->cache may be NULL at request finalising, etc. *) test if updating request does not complete correctly
2010-07-19proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypassIgor Sysoev1-5/+7
2010-07-16rename ngx_http_file_cache_create() to ngx_http_file_cache_new()Igor Sysoev1-1/+1
2010-07-15ngx_http_file_cache_create()Igor Sysoev1-0/+1
2010-07-14use ngx_http_test_predicates(), ngx_http_set_predicate_slot()Igor Sysoev1-4/+0
delete ngx_http_cache(), ngx_http_no_cache_set_slot()
2010-05-24proxy_no_cache and fastcgi_no_cacheIgor Sysoev1-0/+5
2009-08-28FreeBSD and Linux AIO supportIgor Sysoev1-0/+1
2009-08-10cache loader processIgor Sysoev1-0/+1
2009-06-18$upstream_cache_statusIgor Sysoev1-3/+7
2009-06-06proxy_cache_use_stale/fastcgi_cache_use_stale updatingIgor Sysoev1-1/+3
2009-06-06delete useless r->cache->usesIgor Sysoev1-1/+0
2009-06-06remove remnantsIgor Sysoev1-7/+1
2009-04-18support attaching to an existent Win32 shared memoryIgor Sysoev1-5/+10
2009-03-30introduce cache manager instead of cache cleanerIgor Sysoev1-3/+10
2009-03-23a prelimiary proxy cache supportIgor Sysoev1-110/+80
2004-12-21nginx-0.1.13-RELEASE importrelease-0.1.13Igor Sysoev1-7/+20
*) Feature: the server_names_hash and server_names_hash_threshold directives. *) Bugfix: the *.domain.tld names in the "server_name" directive did not work. *) Bugfix: the %request_length log parameter logged the incorrect length.
2004-12-02nginx-0.1.11-RELEASE importrelease-0.1.11Igor Sysoev1-0/+5
*) Feature: the worker_priority directive. *) Change: both tcp_nopush and tcp_nodelay directives affect the transferred response. *) Bugfix: nginx did not call initgroups(). Thanks to Andrew Sitnikov and Andrei Nigmatulin. *) Change: now the ngx_http_autoindex_module shows the file size in the bytes. *) Bugfix: the ngx_http_autoindex_module returned the 500 error if the broken symlink was in a directory. *) Bugfix: the files bigger than 4G could not be transferred using sendfile. *) Bugfix: if the backend was resolved to several backends and there was an error while the response waiting then process may got caught in an endless loop. *) Bugfix: the worker process may exit with the "unknown cycle" message when the /dev/poll method was used. *) Bugfix: "close() channel failed" errors. *) Bugfix: the autodetection of the "nobody" and "nogroup" groups. *) Bugfix: the send_lowat directive did not work on Linux. *) Bugfix: the segmentation fault occurred if there was no events section in configuration. *) Bugfix: nginx could not be built on OpenBSD. *) Bugfix: the double slashes in "://" in the URI were converted to ":/".
2004-11-25nginx-0.1.9-RELEASE importrelease-0.1.9Igor Sysoev1-6/+14
*) Bugfix: the proxied request was sent without arguments if the request contains "//", "/./", "/../" or "%XX". *) Bugfix: the large compressed responses may be transferred not completely. *) Bugfix: the files bigger than 2G was not transferred on Linux that does not support sendfile64(). *) Bugfix: while the build configuration on Linux the --with-poll_module parameter was required; the bug had appeared in 0.1.8.
2004-09-29nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyrightIgor Sysoev1-1/+1
2004-09-28nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused filesIgor Sysoev1-0/+6
2004-05-28nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_tIgor Sysoev1-1/+1
2004-02-23nginx-0.0.2-2004-02-23-23:57:12 importIgor Sysoev1-0/+3