Re: [SMARTY-DEV] Making Smarty's cache HTTP header aware
[email protected] ("Luke Baker") Thu, 8 Nov 2007 08:42:14 -0500
| Newsgroups | php.smarty.dev |
|---|---|
| Message-ID | <[email protected]> |
Ah yes, here's the text of the patch. This is just an added bonus
feature for people using PHP5. If applied, Smarty will still work as
before with earlier PHP versions.
Luke
Index: internals/core.write_cache_file.php
===================================================================
--- internals/core.write_cache_file.php
+++ internals/core.write_cache_file.php
@@ -60,6 +60,9 @@
$params['results'] = implode('', $results);
}
$smarty->_cache_info['cache_serials'] = $smarty->_cache_serials;
+ if (version_compare('5', phpversion(), "<") &&
function_exists('headers_list')) {
+ $smarty->_cache_info['headers'] = headers_list();
+ }
// prepend the cache header info into cache file
$_cache_info = serialize($smarty->_cache_info);
Index: Smarty.class.php
===================================================================
--- Smarty.class.php
+++ Smarty.class.php
@@ -1212,10 +1212,18 @@
header('HTTP/1.1 304 Not Modified');
} else {
+ if (isset($this->_cache_info['headers'])) {
+ foreach ($this->_cache_info['headers'] as $h)
+ header($h);
+ }
header('Last-Modified: '.$_gmt_mtime);
echo $_smarty_results;
}
} else {
+ if (isset($this->_cache_info['headers'])) {
+ foreach ($this->_cache_info['headers'] as $h)
+ header($h);
+ }
echo $_smarty_results;
}
error_reporting($_smarty_old_error_level)
On Nov 8, 2007 2:52 AM, Hielke Hoeve <[email protected]> wrote:
> On 07/11/2007, Luke Baker <[email protected]> wrote:
> > Attached is the changes I made against Smarty 2.6.18. I'd appreciate
> > consideration for adding these changes to the Smarty core.
>
> There is no attachment, sorry.
>
> Hielke
>
> --
> Smarty Development Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>