Browse Source

- generate ETag and Last-Modified headers for mod_ssi based on newest modified include (#1491)

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2053 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.19
Elan Ruusamäe 14 years ago
parent
commit
3078b31568
  1. 1
      NEWS
  2. 37
      src/mod_ssi.c

1
NEWS

@ -18,6 +18,7 @@ NEWS
* add IdleServers and Scoreboard directives in ?auto mode for mod_status (#1507)
* open log immediately after daemonizing, fixes SIGPIPEs on startup (#165)
* HTTPS env var should be "on" when using mod_extforward and the X-Forwarded-Proto header is set. (#1499)
* generate ETag and Last-Modified headers for mod_ssi based on newest modified include (#1491)
- 1.4.18 - 2007-09-09

37
src/mod_ssi.c

@ -36,6 +36,11 @@
#include <sys/filio.h>
#endif
#include "etag.h"
/* The newest modified time of included files for include statement */
static volatile time_t include_file_last_mtime = 0;
/* init the plugin data */
INIT_FUNC(mod_ssi_init) {
plugin_data *p;
@ -575,6 +580,11 @@ static int process_ssi_stmt(server *srv, connection *con, plugin_data *p,
break;
case SSI_INCLUDE:
chunkqueue_append_file(con->write_queue, p->stat_fn, 0, st.st_size);
/* Keep the newest mtime of included files */
if (st.st_mtime > include_file_last_mtime)
include_file_last_mtime = st.st_mtime;
break;
}
} else {
@ -912,6 +922,9 @@ static int mod_ssi_handle_request(server *srv, connection *con, plugin_data *p)
build_ssi_cgi_vars(srv, con, p);
p->if_is_false = 0;
/* Reset the modified time of included files */
include_file_last_mtime = 0;
if (-1 == stream_open(&s, con->physical.path)) {
log_error_write(srv, __FILE__, __LINE__, "sb",
"stream-open: ", con->physical.path);
@ -1010,6 +1023,30 @@ static int mod_ssi_handle_request(server *srv, connection *con, plugin_data *p)
response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/html"));
{
/* Generate "ETag" & "Last-Modified" headers */
stat_cache_entry *sce = NULL;
time_t lm_time = 0;
buffer *mtime = NULL;
stat_cache_get_entry(srv, con, con->physical.path, &sce);
etag_mutate(con->physical.etag, sce->etag);
response_header_overwrite(srv, con, CONST_STR_LEN("ETag"), CONST_BUF_LEN(con->physical.etag));
if (sce->st.st_mtime > include_file_last_mtime)
lm_time = sce->st.st_mtime;
else
lm_time = include_file_last_mtime;
mtime = strftime_cache_get(srv, lm_time);
response_header_overwrite(srv, con, CONST_STR_LEN("Last-Modified"), CONST_BUF_LEN(mtime));
}
/* Reset the modified time of included files */
include_file_last_mtime = 0;
/* reset physical.path */
buffer_reset(con->physical.path);

Loading…
Cancel
Save