Feature #768
closedmod_cml - output_expires
Description
I use lighttpd-1.4.11 in production with mod_cml.
I needed to set the "Expires" from lua on some pages so i coded it.
After about a month of use i thought maybe you would be interested in adding this feature.
Lua Programming:
output_expires = <num>
mod_cml_lua.c:
(i added this right after the code with "output_contenttype") /* get the expires from lua in seconds and generate the appropriate * response. values are in seconds (offset) from current time. */ if (0 == lua_to_c_get_string(L, "output_expires", b)) { char timebuf[sizeof("Thu, 09 May 1985 13:13:13 GMT")]; char *err; int num; time_t t = 0; size_t len; buffer *cc = buffer_init(); /* cc = cache-control */ /* get the value from lua to an integer */ num = strtol(b->ptr, &err, 10); if (*err != NULL) { log_error_write(srv, __FILE__, __LINE__, "s", "outout_expires not a valid <num>", b); return HANDLER_ERROR; } /* current time + offset */ time(&t); t += num; if (0 == (len = strftime(timebuf, sizeof(timebuf), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&(t))))) { /* could not set expire header, out of mem */ return HANDLER_GO_ON; } /* HTTP/1.0 */ response_header_overwrite(srv, con, CONST_STR_LEN("Expires"), timebuf, sizeof(timebuf) - 1); /* HTTP/1.1 */ if (num != 0) { buffer_copy_string_len(cc, "max-age=", 8); buffer_append_string(cc, b->ptr); } else buffer_copy_string_len(cc, "no-cache", 8); buffer_append_string_len(cc, ", must-revalidate", 17); response_header_overwrite(srv, con, CONST_STR_LEN("Cache-Control"), CONST_BUF_LEN(cc)); buffer_free(cc); }
I have added the "must-revalidate" because i needed it, but you can just comment it out.
I use lighttpd-1.4.11 release (no - svn).
thanks,
-- amix.
-- duke.amix
Updated by stbuehler over 16 years ago
- Status changed from New to Fixed
- Resolution set to wontfix
mod_cml is deprecated.
Updated by gstrauss about 1 year ago
- Description updated (diff)
- Status changed from Wontfix to Obsolete
- ASK QUESTIONS IN Forums set to No
mod_cml is no longer part of the lighttpd base
For replacement, see lua mod_cml
For much more powerful features, review all the features of mod_magnet
lighttpd mod_magnet will add Expires for HTTP/1.0 and Cache-Control for HTTP/1.1 when lua scripts use method http-response-send-file
on the object returned by lighty.c.stat("/path")
e.g. lua mod_staticfile
Also available in: Atom