When we use SSI ( Server Side Include ) in Apache web server, it removes content-length header from the response sent to client. Which make sense as how Apache will calculate content length of a file on a file system. More on this can  be read from here.

Now the methods given in Apache website are for adding “Last-modified” header but not for “Content-Length” header. In some cases it is necessary to send content-length header back as some CDN providers need this header to cache the things.

Here are some methods that can be tried ( as per your need )

First method Use Trans-encoding as chunked. More on this can be read here.

Second method is , disable Apache behavior of removing these headers while serving SSI. Again for content-length header it can cause problems here as if you have a file “ssienable.html” which is having other Includes, then Apache will send content length of this file as given by OS and in actual it may have more content due to includes . Last-modified header works fine with this method. To do this you need to compile mod_include  again.Just change the below mentioned lines in mod_include.c:

/* Always unset the content-length.  There is no way to know if
* the content will be modified at some point by send_parsed_content.
* It is very possible for us to not find any content in the first
* 9k of the file, but still have to modify the content of the file.
* If we are going to pass the file through send_parsed_content, then
* the content-length should just be unset.
*/
apr_table_unset(f->r->headers_out, “Content-Length”);

/* Always unset the Last-Modified field – see RFC2616 – 13.3.4.
* We don’t know if we are going to be including a file or executing
* a program which may change the Last-Modified header or make the
* content completely dynamic.  Therefore, we can’t support these
* headers.
* Exception: XBitHack full means we *should* set the Last-Modified field.
*/

/* Assure the platform supports Group protections */
if ((conf->xbithack == XBITHACK_FULL)
&& (r->finfo.valid & APR_FINFO_GPROT)
&& (r->finfo.protection & APR_GEXECUTE)) {
ap_update_mtime(r, r->finfo.mtime);
ap_set_last_modified(r);
}
else {
apr_table_unset(f->r->headers_out, “Last-Modified”);
}

Third approach is to use mod_perl output filter for content-length header as explained here.

Fourth approach is to insert Last-modified header in BIGIP/LTM using a simple iRule :

when HTTP_REQUEST {
set mytime [clock seconds]
set mod_time [expr { $mytime – 604800 }] // This is to change the value to 1 week back.
// You can add or subtract as per requirement
}

when HTTP_RESPONSE {
if { [HTTP::header “Content-Type”] ends_with “html” }  {
HTTP::header insert Last-Modified “[clock format $mod_time -gmt 1 -format “%a, %d %b %Y %T %Z”]”
}

}

All of the above methods should be very carefully tested before putting in prod