The Slim Framework support forum has moved to http://discourse.slimframework.com. This Tender forum is no longer maintained or monitored.

HTTP Caching

Kenneth's Avatar

Kenneth

21 Feb, 2016 08:57 PM

Hello,

I am using the HTTP Caching for Slim 3 (http://www.slimframework.com/docs/features/caching.html).

Therefore i have added what was required to my index.php, but i still get the response code 200.
I think is should get a 304 not modified? And the preformance is not improving from the request.

My $json is normally a request to another api, that takes ~250ms. After i added the HTTP caching is still give ~250ms every request.

My index.php & response header looks like this, i hope someone can help me with this (sorry for my english):

Response Header:
Cache-Control:public, max-age=86400
Connection:Keep-Alive
Content-Encoding:gzip
Content-Length:38
Content-Type:application/json
Date:Sun, 21 Feb 2016 20:49:38 GMT
Keep-Alive:timeout=2, max=60
Server:Apache/2
Vary:Accept-Encoding,User-Agent
X-Powered-By:PHP/5.6.16

Index.php:
<?php

require './vendor/autoload.php';

$container = new \Slim\Container; $container['cache'] = function () { return new \Slim\HttpCache\CacheProvider(); };

$app = new \Slim\App($container); $app->add(new \Slim\HttpCache\Cache('public', 86400));

$app->get('/json', function ($req, $res, $args) {

$json = json_encode(array('Hello' => 'World!'));

$body = $res->getBody();
    $body->write($json);

return $res->withHeader('Content-Type', 'application/json')->withBody($body);

});

$app->run();

  1. 1 Posted by sagarkhna999 on 09 May, 2016 11:54 AM

    sagarkhna999's Avatar

    good Sidhu's incessant laughter, it was substantially extra than that. http://thekapilsharmashowtv.com He offered Grover his first of all period of time. great.

  2. 2 Posted by raj on 25 Nov, 2016 06:55 AM

    raj's Avatar

    good the marriage journalist Association, Wedding amp http://bigphotographers.com/ His inventive eye and distinctive perspective leads to attractive pictures that implement color, nice.

  3. 3 Posted by davis on 04 Apr, 2017 06:37 AM

    davis's Avatar

    Then I have to state Kodi is the very best choice https://kodidownloadtv.com/kodi-for-iphone-ipad-ios-download-app to the above-given actions and screenshots you could be other attributes.

  4. 4 Posted by sania on 23 Apr, 2017 06:58 AM

    sania's Avatar

    Jailbroken device to install this app, it functions penalty https://iyoutvplayer.com at the firm meeting. You have some crucial service video.

  5. 5 Posted by Chris Dean on 06 May, 2017 12:17 PM

    Chris Dean's Avatar

    Do you guys know about the Borderlands 3 Features

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac