blob: f9bf66196ad3646c961aeab040b58a2ac8586e93 [file] [log] [blame]
Igor Sysoev65977492003-11-02 22:56:18 +00001#ifndef _NGX_HTTP_CACHE_H_INCLUDED_
2#define _NGX_HTTP_CACHE_H_INCLUDED_
3
4
5#include <ngx_config.h>
6#include <ngx_core.h>
Igor Sysoevf60b1a52003-11-04 17:09:19 +00007#include <ngx_http.h>
Igor Sysoev65977492003-11-02 22:56:18 +00008
9
10typedef struct {
11 time_t expires;
12 time_t last_modified;
Igor Sysoevcf80a702003-11-03 22:20:44 +000013 time_t date;
Igor Sysoev65977492003-11-02 22:56:18 +000014 off_t length;
Igor Sysoev65977492003-11-02 22:56:18 +000015} ngx_http_cache_header_t;
16
17
18typedef struct {
Igor Sysoev65977492003-11-02 22:56:18 +000019 ngx_http_cache_header_t header;
Igor Sysoeva1512b12003-11-03 17:33:31 +000020 size_t key_len;
Igor Sysoev65977492003-11-02 22:56:18 +000021 char key[0];
Igor Sysoeva1512b12003-11-03 17:33:31 +000022} ngx_http_cache_file_t;
Igor Sysoev65977492003-11-02 22:56:18 +000023
24
25typedef struct {
26 u_int32_t crc;
27 ngx_str_t key;
28 ngx_fd_t fd;
29 off_t size;
30 void *data; /* mmap, memory */
31 time_t accessed;
32 time_t last_modified;
33 time_t updated; /* no needed with kqueue */
34 int refs;
35 int flags;
36} ngx_http_cache_entry_t;
37
38
39typedef struct {
40 ngx_file_t file;
41 ngx_str_t key;
42 ngx_path_t *path;
43 ngx_hunk_t *buf;
44 ngx_http_cache_header_t header;
Igor Sysoeva1512b12003-11-03 17:33:31 +000045 ssize_t header_size;
Igor Sysoev65977492003-11-02 22:56:18 +000046} ngx_http_cache_ctx_t;
47
48
Igor Sysoevcf80a702003-11-03 22:20:44 +000049#define NGX_HTTP_CACHE_STALE 1
50#define NGX_HTTP_CACHE_AGED 2
Igor Sysoeva1512b12003-11-03 17:33:31 +000051
52
Igor Sysoev65977492003-11-02 22:56:18 +000053int ngx_http_cache_get_file(ngx_http_request_t *r, ngx_http_cache_ctx_t *ctx);
54int ngx_http_cache_update_file(ngx_http_request_t *r,ngx_http_cache_ctx_t *ctx,
55 ngx_str_t *temp_file);
56
57
58
Igor Sysoev65977492003-11-02 22:56:18 +000059#endif /* _NGX_HTTP_CACHE_H_INCLUDED_ */