我試圖使用私人/公共緩存,以避免檢索所有用於構建主頁內容的數據。這是安靜的靜態內容。使用symfony2 http動態緩存動態頭緩存策略
我試着這樣做。
$response->setMaxAge(600);
// mark the response as either public or private
$response->setPublic();
$response->setPrivate();
// set the private or shared max age
$response->setMaxAge(2000);
$response->setSharedMaxAge(2000);
$response->setETag(md5($response->getContent()));
$response->isNotModified($this->getRequest());
// set a custom Cache-Control directive
$response->headers->addCacheControlDirective('must-revalidate', true);
,但我有一個可以真正改變動態語言一樣&貨幣選擇一些小的信息。
如果用戶決定更改語言或貨幣時如何更改內容?
它目前正在爲語言工作,因爲URL是不同的home.site/fr或home.site/en。
但貨幣的信息不在網址中,而其他信息如驗證與否也不在網址中。
那麼如何使用Http緩存並使事情真正符合用戶操作?
感謝您的幫助。
號Yoni