1、代码设置: (注释方式) use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
/** @Cache(smaxage="3600", maxage="3600", public=true) */ (手动方式) $cacheTime = 3600; $response = new JsonResponse($channelDatas, 200); $response->setPublic()->setMaxAge($cacheTime)->setSharedMaxAge($cacheTime); 2、nginx 配置 location ~ \.php($|/) { include fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_cache fastcgicache; //必须加上 }