1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef MOD_DISK_CACHE_H
18 #define MOD_DISK_CACHE_H
21 * include for mod_disk_cache: Disk Based HTTP 1.1 Cache.
24 #define VARY_FORMAT_VERSION 3
25 #define DISK_FORMAT_VERSION 4
27 #define CACHE_HEADER_SUFFIX ".header"
28 #define CACHE_DATA_SUFFIX ".data"
29 #define CACHE_VDIR_SUFFIX ".vary"
31 #define AP_TEMPFILE_PREFIX "/"
32 #define AP_TEMPFILE_BASE "aptmp"
33 #define AP_TEMPFILE_SUFFIX "XXXXXX"
34 #define AP_TEMPFILE_BASELEN strlen(AP_TEMPFILE_BASE)
35 #define AP_TEMPFILE_NAMELEN strlen(AP_TEMPFILE_BASE AP_TEMPFILE_SUFFIX)
36 #define AP_TEMPFILE AP_TEMPFILE_PREFIX AP_TEMPFILE_BASE AP_TEMPFILE_SUFFIX
39 /* Indicates the format of the header struct stored on-disk. */
41 /* The HTTP status code returned for this response. */
43 /* The size of the entity name that follows. */
45 /* The number of times we've cached this entity. */
46 apr_size_t entity_version;
47 /* Miscellaneous time values. */
50 apr_time_t request_time;
51 apr_time_t response_time;
64 * Pointed to by cache_object_t::vobj
66 typedef struct disk_cache_object {
67 const char *root; /* the location of the cache directory */
70 disk_cache_file_t data; /* data file structure */
71 disk_cache_file_t hdrs; /* headers file structure */
72 disk_cache_file_t vary; /* vary file structure */
73 const char *hashfile; /* Computed hash key for this URI */
74 const char *name; /* Requested URI without vary bits - suitable for mortals. */
75 const char *key; /* On-disk prefix; URI with Vary bits (if present) */
76 apr_off_t file_size; /* File size of the cached data file */
77 disk_cache_info_t disk_info; /* Header information. */
78 apr_bucket_brigade *bb; /* Set aside brigade */
79 apr_off_t offset; /* Max size to set aside */
80 apr_time_t timeout; /* Max time to set aside */
81 int done; /* Is the attempt to cache complete? */
82 } disk_cache_object_t;
86 * mod_disk_cache configuration
88 /* TODO: Make defaults OS specific */
89 #define CACHEFILE_LEN 20 /* must be less than HASH_LEN/2 */
90 #define DEFAULT_DIRLEVELS 2
91 #define DEFAULT_DIRLENGTH 2
92 #define DEFAULT_MIN_FILE_SIZE 1
93 #define DEFAULT_MAX_FILE_SIZE 1000000
94 #define DEFAULT_READSIZE 0
95 #define DEFAULT_READTIME 0
98 const char* cache_root;
99 apr_size_t cache_root_len;
100 int dirlevels; /* Number of levels of subdirectories */
101 int dirlength; /* Length of subdirectory names */
102 apr_off_t minfs; /* minimum file size for cached files */
103 apr_off_t maxfs; /* maximum file size for cached files */
107 apr_off_t readsize; /* maximum data to attempt to cache in one go */
108 apr_time_t readtime; /* maximum time taken to cache in one go */
111 } disk_cache_dir_conf;
113 #endif /*MOD_DISK_CACHE_H*/