PHP: Slim Framework - using different response header per route -
is possible use different response header in every route?
you can see sourcecode here:
- indexfile:
https://github.com/damian89/slim-filecaching/blob/master/index.php
- caching middleware:
https://github.com/damian89/slim-filecaching/blob/master/caching.slim.php
i have 2 simple routes. use caching in first case, not second 1 - it's not working.
if place following code directly above first route works:
$app->response->headers->set( pagecaching::slim_page_cacher, pagecaching::cache_enabled);
but in case both routes cached.
any ideas?
thank you!
to me looks caching logic in middleware reversed. in /no-cache/
route set slim_page_cacher
header cache_disabled
value 1
.
in middleware compare slim_page_cacher
header cache_enabled
value 0
. becomes:
$this->skip_caching (1 == 0); /* evaluates false */
this means skip_caching
false , page cached.
in general idea avoid double negatives in code. make code hard read , understand. idea follow conventions , assume 1 === true
, 0 === false
, not vice versa.