{"action":"opened","issue":{"url":"https://api.github.com/repos/FriendsOfSymfony/FOSUserBundle/issues/1770","labels_url":"https://api.github.com/repos/FriendsOfSymfony/FOSUserBundle/issues/1770/labels{/name}","comments_url":"https://api.github.com/repos/FriendsOfSymfony/FOSUserBundle/issues/1770/comments","events_url":"https://api.github.com/repos/FriendsOfSymfony/FOSUserBundle/issues/1770/events","html_url":"https://github.com/FriendsOfSymfony/FOSUserBundle/issues/1770","id":59920692,"number":1770,"title":"Can and Should I cache symfony2 getUser()","user":{"login":"Don87","id":5156320,"avatar_url":"https://avatars.githubusercontent.com/u/5156320?v=3","gravatar_id":"","url":"https://api.github.com/users/Don87","html_url":"https://github.com/Don87","followers_url":"https://api.github.com/users/Don87/followers","following_url":"https://api.github.com/users/Don87/following{/other_user}","gists_url":"https://api.github.com/users/Don87/gists{/gist_id}","starred_url":"https://api.github.com/users/Don87/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Don87/subscriptions","organizations_url":"https://api.github.com/users/Don87/orgs","repos_url":"https://api.github.com/users/Don87/repos","events_url":"https://api.github.com/users/Don87/events{/privacy}","received_events_url":"https://api.github.com/users/Don87/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-03-05T08:35:06Z","updated_at":"2015-03-05T08:35:06Z","closed_at":null,"body":"I am using Symfony ( current version 2.6.4 ) whenever I want to check if a user is loggedin ( I am also using FOSUserBundle ) I use $user = $this->getUser(); in my controller which works out just fine but if I open 10 links in 1 second this query is repeated for all 10 pages in that second, not so ideal in my option. So my question is, is there a way to cache this query for say 60 seconds and is it even advisable, will it affect new registrations or something. I am using APC as my doctrine cache but if someone knows the answer please also tell us how to use other ways incase other people also wonder how to do this. Thanks. I have also posted this on Stackoverflow reference here\r\n\r\nhttp://stackoverflow.com/questions/28830086/can-and-should-i-cache-symfony2-getuser\r\n\r\nAnd a very similar question points to FOSUserBundle as the possible issue reference here\r\n\r\nhttp://stackoverflow.com/questions/27608342/symfony2-fosuserbundle-not-using-usermanager-to-provide-cached-user-entity "}}