I'm trying to use mod\_cache to cache dynamically generated content. This is my Apache config:

```xml
CacheEnable mem /
MCacheSize 4096
MCacheMaxObjectCount 100
MCacheMinObjectSize 1
MCacheMaxObjectSize 2048
CacheIgnoreCacheControl On
CacheIgnoreNoLastMod On
CacheStorePrivate On
CacheStoreNoStore On

<Location /cgi-bin>
    SetHandler cgi-script
    Options +ExecCGI
</Location>

```

And this is one CGI script (just for testing):

```js
#!/opt/app/phantomjs/bin/phantomjs
var date = new Date('Sun, 01 Jan 2012 00:00:00 GMT');
console.log('Last-Modified: '+ date.toUTCString());
console.log('Cache-Control: max-age=' + (365 * 24 * 60 * 60)+ ', public');
date.setDate(date.getDate() + 365);
console.log('Expires: '+ date.toUTCString() + '\n\n');

// lengthy operation here...

console.log(content);

```

This basically works. But **what happens** is if a client requests a cgi-bin with an `If-Modified-Since` header:

1. CGI-script streams headers
2. some seconds delay
3. CGI-script streams body
4. Apache sends 304

That makes no sense to me. Apache waits for the whole response before it sends a not-modified response.

**What I expected**:

1. CGI-script streams headers
2. Apache sends 304
3. CGI-script is canceled or body of CGI-script is discarded

Is there any way to get it done?