Re: [SMARTY-DEV] Making Smarty's cache HTTP header aware

[email protected] ("Luke Baker") Thu, 8 Nov 2007 14:26:20 -0500
Newsgroups php.smarty.dev
Message-ID <[email protected]>
On Nov 8, 2007 2:06 PM, boots <[email protected]> wrote:
[snip]
>
> That said, Luke, can you give more detail on why this is important? Thanks!

Sure, I'd be happy to.  The particular case that I ran into had to do
with enabling client-side caching using the Cache-Control  HTTP
header.  In my PHP code, I used something like the following:
header("Cache-Control: max-age=21600, public");

That header call was in PHP code that only gets run when the smarty
cache does not already exist.  Therefore, when there is no cached file
for this request, that header() gets called along with additional PHP
code.  However, any subsequent requests will be served from the Smarty
cache, which returns only the content that I had sent previously, but
not the headers.

Without my patch, Smarty simply caches the content of the HTTP
response.  In most cases this is sufficient.  However, the HTTP
headers _and_ the content are what define an HTTP response, not just
the content.  My patch adds caching of the HTTP headers used in the
response alongside the content.

Thanks,

Luke Baker