Minify CSS Cache-Control Headers

81 views
Skip to first unread message

Matt Dean

unread,
Jul 20, 2017, 11:27:11 AM7/20/17
to Fat-Free Framework
So I have minify working as;

 public function minify($f3, $args) {
        $files = preg_replace('/(\.+\/)/', '', $_GET['files']);
        echo \Web::instance()->minify($files, null, true);
    }

and am calling it as;

<link rel="stylesheet" type="text/css" href="/minify?files=/css/reset.css,/css/style.css" />

and my route is;

GET /minify = \controller\Controller->minify, 3600

The minification works and the files are cached in the local file system but the response has a header of Cache-Control:no-store, no-cache, must-revalidate instead of a time

How do I change this?

Thanks

ikkez

unread,
Jul 20, 2017, 8:42:42 PM7/20/17
to Fat-Free Framework
Your setup looks good to me.

This is handled by the f3->expire method, which should be called automatically when a route caching is active,.. it should happen right here https://github.com/bcosca/fatfree-core/blob/master/base.php#L1587-L1602

I'll test it here

Matt Dean

unread,
Jul 21, 2017, 4:06:53 AM7/21/17
to f3-fra...@googlegroups.com
So echoing out the $ttl at 1602 its showing the 3600, also if I add $f3->expire(3600); before the echo in the minify method the cache works as expected.
Looks like something else is unsetting it after the 1602 line.

ikkez

unread,
Jul 21, 2017, 7:31:11 AM7/21/17
to Fat-Free Framework
do you have some extra rules in your .htaccess or in your nginx config maybe?

Matt Dean

unread,
Jul 21, 2017, 7:47:58 AM7/21/17
to Fat-Free Framework
Just mod_deflate and the usual rewrites. 
Can't see how they would affect expire in base but not when it is set in the minify method though.

xfra35

unread,
Jul 22, 2017, 4:04:15 PM7/22/17
to Fat-Free Framework
It could also be caused by:
  • the PHP session cache_limiter, if for some reason, you started a session on this route
  • a proxy standing in front of Apache (Squid, Varnish, etc.)

Matt Dean

unread,
Jul 24, 2017, 9:42:12 AM7/24/17
to f3-fra...@googlegroups.com
Turns out one of our other devs had put some extra code in the main controller that was causing this issue. 
I moved this out to its own controller which fixed the issue. Thanks for trying to help :) 
Reply all
Reply to author
Forward
0 new messages