Changeset 2053

Show
Ignore:
Timestamp:
01/18/2008 09:21:07 AM (9 months ago)
Author:
glen
Message:

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

Location:
branches/lighttpd-1.4.x
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • branches/lighttpd-1.4.x/NEWS

    r2052 r2053  
    1919  * open log immediately after daemonizing, fixes SIGPIPEs on startup  (#165) 
    2020  * HTTPS env var should be "on" when using mod_extforward and the X-Forwarded-Proto header is set. (#1499) 
     21  * generate ETag and Last-Modified headers for mod_ssi based on newest modified include (#1491) 
    2122 
    2223- 1.4.18 - 2007-09-09 
  • branches/lighttpd-1.4.x/src/mod_ssi.c

    r1951 r2053  
    3636#include <sys/filio.h> 
    3737#endif 
     38 
     39#include "etag.h" 
     40 
     41/* The newest modified time of included files for include statement */ 
     42static volatile time_t include_file_last_mtime = 0; 
    3843 
    3944/* init the plugin data */ 
     
    576581                        case SSI_INCLUDE: 
    577582                                chunkqueue_append_file(con->write_queue, p->stat_fn, 0, st.st_size); 
     583 
     584                                /* Keep the newest mtime of included files */ 
     585                                if (st.st_mtime > include_file_last_mtime) 
     586                                  include_file_last_mtime = st.st_mtime; 
     587 
    578588                                break; 
    579589                        } 
     
    912922        build_ssi_cgi_vars(srv, con, p); 
    913923        p->if_is_false = 0; 
     924 
     925        /* Reset the modified time of included files */ 
     926        include_file_last_mtime = 0; 
    914927 
    915928        if (-1 == stream_open(&s, con->physical.path)) { 
     
    10111024        response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/html")); 
    10121025 
     1026  { 
     1027        /* Generate "ETag" & "Last-Modified" headers */ 
     1028 
     1029                stat_cache_entry *sce = NULL; 
     1030                time_t lm_time = 0; 
     1031                buffer *mtime = NULL; 
     1032 
     1033                stat_cache_get_entry(srv, con, con->physical.path, &sce); 
     1034 
     1035                etag_mutate(con->physical.etag, sce->etag); 
     1036                response_header_overwrite(srv, con, CONST_STR_LEN("ETag"), CONST_BUF_LEN(con->physical.etag)); 
     1037 
     1038                if (sce->st.st_mtime > include_file_last_mtime) 
     1039                        lm_time = sce->st.st_mtime; 
     1040                else 
     1041                        lm_time = include_file_last_mtime; 
     1042 
     1043                mtime = strftime_cache_get(srv, lm_time); 
     1044                response_header_overwrite(srv, con, CONST_STR_LEN("Last-Modified"), CONST_BUF_LEN(mtime)); 
     1045  } 
     1046 
     1047        /* Reset the modified time of included files */ 
     1048        include_file_last_mtime = 0; 
     1049 
    10131050        /* reset physical.path */ 
    10141051        buffer_reset(con->physical.path);