Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
| Comment: | Initial work on setting Cache-Control headers
The bit that foxed me was understanding getopts and that the "h" needed a ":" This definitely and utterly sets a header. It doesn't seem that it's recognised - https://developers.google.com/speed/pagespeed/insights/ and here: - http://highloadtools.com/cachecontrol But what can you do? At the moment this just sets a header everywhere for everything being served. |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
a29fb4fb10ecaeea65aecf2c9b78a47a |
| User & Date: | atomicules 2017-11-25 19:08:28 |
|
2017-11-25
| ||
| 22:13 |
Set cache-control only for images
A bit of an intermediate commit, just investigating what works. I think really "image" "max-age=604800" The bit I'm then missing is how to set a catch all or "owtelse" cache-control? | |
| 19:08 |
Initial work on setting Cache-Control headers
The bit that foxed me was understanding getopts and that the "h" needed a ":" This definitely and utterly sets a header. It doesn't seem that it's recognised - https://developers.google.com/speed/pagespeed/insights/ and here: - http://highloadtools.com/cachecontrol But what can you do? At the moment this just sets a header everywhere for everything being served. | |
|
2017-11-24
| ||
| 21:16 | Add version 20170201 of Bozohttpd check-in: b786821675 user: atomicules tags: trunk | |
Changes to bozohttpd.c.
| ︙ | ︙ | |||
1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 |
struct tm *tm;
tm = gmtime(&sbp->st_mtime);
strftime(filedate, sizeof filedate,
"%a, %d %b %Y %H:%M:%S GMT", tm);
bozo_printf(httpd, "Last-Modified: %s\r\n", filedate);
}
if (type && *type)
bozo_printf(httpd, "Content-Type: %s\r\n", type);
if (encoding && *encoding)
bozo_printf(httpd, "Content-Encoding: %s\r\n", encoding);
if (sbp) {
if (request->hr_have_range) {
len = request->hr_last_byte_pos -
| > > | 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 |
struct tm *tm;
tm = gmtime(&sbp->st_mtime);
strftime(filedate, sizeof filedate,
"%a, %d %b %Y %H:%M:%S GMT", tm);
bozo_printf(httpd, "Last-Modified: %s\r\n", filedate);
}
if (httpd->cache_control_headers)
bozo_printf(httpd, "Cache-Control: %s\r\n", httpd->cache_control_headers);
if (type && *type)
bozo_printf(httpd, "Content-Type: %s\r\n", type);
if (encoding && *encoding)
bozo_printf(httpd, "Content-Encoding: %s\r\n", encoding);
if (sbp) {
if (request->hr_have_range) {
len = request->hr_last_byte_pos -
|
| ︙ | ︙ | |||
2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 |
}
if ((cp = bozo_get_pref(prefs, "directory indexing")) != NULL &&
strcmp(cp, "true") == 0) {
httpd->dir_indexing = 1;
}
if ((cp = bozo_get_pref(prefs, "public_html")) != NULL) {
httpd->public_html = bozostrdup(httpd, NULL, cp);
}
httpd->server_software =
bozostrdup(httpd, NULL, bozo_get_pref(prefs, "server software"));
httpd->index_html =
bozostrdup(httpd, NULL, bozo_get_pref(prefs, "index.html"));
/*
| > > > | 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 |
}
if ((cp = bozo_get_pref(prefs, "directory indexing")) != NULL &&
strcmp(cp, "true") == 0) {
httpd->dir_indexing = 1;
}
if ((cp = bozo_get_pref(prefs, "public_html")) != NULL) {
httpd->public_html = bozostrdup(httpd, NULL, cp);
}
if ((cp = bozo_get_pref(prefs, "Cache-Control headers")) != NULL) {
httpd->cache_control_headers = bozostrdup(httpd, NULL, cp);
}
httpd->server_software =
bozostrdup(httpd, NULL, bozo_get_pref(prefs, "server software"));
httpd->index_html =
bozostrdup(httpd, NULL, bozo_get_pref(prefs, "index.html"));
/*
|
| ︙ | ︙ |
Changes to bozohttpd.h.
| ︙ | ︙ | |||
113 114 115 116 117 118 119 120 121 122 123 124 125 126 | int nsock; /* number of above */ struct pollfd *fds; /* current poll fd set */ int request_times; /* # times a request was processed */ int dir_indexing; /* handle directories */ int hide_dots; /* hide .* */ int process_cgi; /* use the cgi handler */ char *cgibin; /* cgi-bin directory */ #ifndef NO_LUA_SUPPORT int process_lua; /* use the Lua handler */ SIMPLEQ_HEAD(, lua_state_map) lua_states; #endif void *sslinfo; /* pointer to ssl struct */ int dynamic_content_map_size;/* size of dyn cont map */ bozo_content_map_t *dynamic_content_map;/* dynamic content map */ | > | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | int nsock; /* number of above */ struct pollfd *fds; /* current poll fd set */ int request_times; /* # times a request was processed */ int dir_indexing; /* handle directories */ int hide_dots; /* hide .* */ int process_cgi; /* use the cgi handler */ char *cgibin; /* cgi-bin directory */ char *cache_control_headers; /* Cache-Control headers */ #ifndef NO_LUA_SUPPORT int process_lua; /* use the Lua handler */ SIMPLEQ_HEAD(, lua_state_map) lua_states; #endif void *sslinfo; /* pointer to ssl struct */ int dynamic_content_map_size;/* size of dyn cont map */ bozo_content_map_t *dynamic_content_map;/* dynamic content map */ |
| ︙ | ︙ |
Changes to main.c.
| ︙ | ︙ | |||
90 91 92 93 94 95 96 97 98 99 100 101 102 103 | bozowarn(httpd, " -b\t\t\tbackground and go into daemon mode"); bozowarn(httpd, " -f\t\t\tkeep daemon mode in the foreground"); bozowarn(httpd, " -i address\t\tbind on this address (daemon mode only)"); bozowarn(httpd, " -P pidfile\t\tpath to the pid file to create"); #endif bozowarn(httpd, " -S version\t\tset server version string"); bozowarn(httpd, " -t dir\t\tchroot to `dir'"); bozowarn(httpd, " -U username\t\tchange user to `user'"); bozowarn(httpd, " -e\t\t\tdon't clean the environment (-t and -U only)"); bozowarn(httpd, " -v virtualroot\tenable virtual host support " "in this directory"); | > | 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | bozowarn(httpd, " -b\t\t\tbackground and go into daemon mode"); bozowarn(httpd, " -f\t\t\tkeep daemon mode in the foreground"); bozowarn(httpd, " -i address\t\tbind on this address (daemon mode only)"); bozowarn(httpd, " -P pidfile\t\tpath to the pid file to create"); #endif bozowarn(httpd, " -S version\t\tset server version string"); bozowarn(httpd, " -h string\t\tCache-Control headers"); bozowarn(httpd, " -t dir\t\tchroot to `dir'"); bozowarn(httpd, " -U username\t\tchange user to `user'"); bozowarn(httpd, " -e\t\t\tdon't clean the environment (-t and -U only)"); bozowarn(httpd, " -v virtualroot\tenable virtual host support " "in this directory"); |
| ︙ | ︙ | |||
146 147 148 149 150 151 152 | bozo_set_defaults(&httpd, &prefs); /* * -r option was removed, do not reuse it for a while */ while ((c = getopt(argc, argv, | | | 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
bozo_set_defaults(&httpd, &prefs);
/*
* -r option was removed, do not reuse it for a while
*/
while ((c = getopt(argc, argv,
"C:EGHI:L:M:P:S:U:VXZ:bc:defh:i:np:st:uv:x:z:")) != -1) {
switch (c) {
case 'L':
#ifdef NO_LUA_SUPPORT
bozoerr(&httpd, 1,
"Lua support is not enabled");
/* NOTREACHED */
|
| ︙ | ︙ | |||
189 190 191 192 193 194 195 196 197 198 199 200 201 202 | bozo_set_pref(&httpd, &prefs, "log to stderr", "true"); break; case 'S': bozo_set_pref(&httpd, &prefs, "server software", optarg); break; case 'Z': #ifdef NO_SSL_SUPPORT bozoerr(&httpd, 1, "ssl support is not enabled"); /* NOT REACHED */ #else /* make sure there's two arguments */ if (argc - optind < 1) | > > > > | 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | bozo_set_pref(&httpd, &prefs, "log to stderr", "true"); break; case 'S': bozo_set_pref(&httpd, &prefs, "server software", optarg); break; case 'h': bozo_set_pref(&httpd, &prefs, "Cache-Control headers", optarg); break; case 'Z': #ifdef NO_SSL_SUPPORT bozoerr(&httpd, 1, "ssl support is not enabled"); /* NOT REACHED */ #else /* make sure there's two arguments */ if (argc - optind < 1) |
| ︙ | ︙ |