mirror of
https://github.com/seigler/simple-php-buffering
synced 2025-07-26 17:26:12 +00:00
initial commit
This commit is contained in:
commit
a71ed489a2
4 changed files with 123 additions and 0 deletions
28
README.md
Normal file
28
README.md
Normal file
|
@ -0,0 +1,28 @@
|
|||
# seigler/simple-php-buffer
|
||||
|
||||
PHP file for basic file-based output buffering
|
||||
|
||||
## Usage
|
||||
```php
|
||||
define('CACHE_PATH', sys_get_temp_dir().'/cache_'); // optional, cache-file location prefix
|
||||
define('CACHE_TIME', 5 * 60); // optional, seconds to cache the output
|
||||
require 'buffer.php';
|
||||
```
|
||||
|
||||
This will send last-modified, expires, and etag headers. If a request includes theetag and
|
||||
modified-since parameters the script can return a 304 not modified.
|
||||
|
||||
This uses output buffering, but it can't buffer headers. If you need to send out a header every time, cached or not, put that header code above the `require`.
|
||||
|
||||
```php
|
||||
Header('Content-type: image/svg+xml; charset=utf-8');
|
||||
Header('Content-Disposition: inline; filename="fancy-chart-' . date('Y-m-d\THisT') . '.svg"');
|
||||
require 'buffer.php';
|
||||
|
||||
// remaining code to generate the chart
|
||||
```
|
||||
|
||||
## Credits
|
||||
|
||||
* Based on http://www.the-art-of-web.com/php/buffer/
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue