Apache Module mod_delay

Available Languages:  en 

Description:Delays Output until told otherwise
Status:Extension
Module Identifier:delay_module
Source File:mod_delay.c
Compatibility:Version 2.2 and later

Summary

mod_delay buffers all output until it receives a note with the key "delay_end". This gives content handlers the opportunity to send headers after they did send content.


Topics

See also

top

Enabling Delaying

Delaying is implemented by the delay filter. This filter stores all content and sends it at the end of the response. This may be suitable for small pages. Delaying can be ended using the delay API.

The filter is added to the output filter chain as usual:


    <Files redirect_at_pages_end.php> 
        SetOutputFilter delay
    </Files> 
    

It is recommended to limit delaying by a Files section or the like. Accidentially delaying a huge file may cause memory problems and delaying without necessity is simply a bit inefficient.

top

Delay API

mod_delay exports a single function for other modules to use. The API is as follows:

APR_DECLARE_OPTIONAL_FN(void, delay_end, (request_rec*) ) ;

The function sends a note that advises the delay filter to end delaying. The note can be sent through the Apache notes API instead as the mod_perl2 example below shows:


    $| = 1;
    print "Something.\n"; 
    # Set the test header.
    $r->headers_out()->set('X-Delaytest',  'mod_delay works');
    # End delaying 
    $r->notes()->set(delay_end => 'dummy');
    

Calling the API function also restores the no_local_copy flag. This is set during delaying to prevent succcessfull ap_meets_conditions calls. After calling the API function delay_end you can call ap_meets_conditions to send a 304. See mod_sqil.c for an example.

top

Available Languages:  en