{"action":"created","issue":{"url":"https://api.github.com/repos/c2corg/v6_api/issues/15","labels_url":"https://api.github.com/repos/c2corg/v6_api/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/c2corg/v6_api/issues/15/comments","events_url":"https://api.github.com/repos/c2corg/v6_api/issues/15/events","html_url":"https://github.com/c2corg/v6_api/pull/15","id":106587996,"number":15,"title":"Add sever side caching","user":{"login":"asaunier","id":1192331,"avatar_url":"https://avatars.githubusercontent.com/u/1192331?v=3","gravatar_id":"","url":"https://api.github.com/users/asaunier","html_url":"https://github.com/asaunier","followers_url":"https://api.github.com/users/asaunier/followers","following_url":"https://api.github.com/users/asaunier/following{/other_user}","gists_url":"https://api.github.com/users/asaunier/gists{/gist_id}","starred_url":"https://api.github.com/users/asaunier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asaunier/subscriptions","organizations_url":"https://api.github.com/users/asaunier/orgs","repos_url":"https://api.github.com/users/asaunier/repos","events_url":"https://api.github.com/users/asaunier/events{/privacy}","received_events_url":"https://api.github.com/users/asaunier/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-09-15T15:58:36Z","updated_at":"2015-09-21T14:18:48Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/c2corg/v6_api/pulls/15","html_url":"https://github.com/c2corg/v6_api/pull/15","diff_url":"https://github.com/c2corg/v6_api/pull/15.diff","patch_url":"https://github.com/c2corg/v6_api/pull/15.patch"},"body":"This PR makes use of dogpile.cache to cache the output of the \"get\" method (as for now lists are not cached).\r\n\r\nI have used \"as is\" the dogpile implementation from c2cgeoportal:\r\nhttps://github.com/camptocamp/c2cgeoportal/blob/1.6/c2cgeoportal/lib/caching.py\r\nWe should probably check if all this functions are needed or generic enough (at first sight yes). It provides for instance a ``set_common_headers()`` function to set the cache control HTTP headers.\r\n\r\nThe backend is currently the standard dogpile.cache.memory backend. dogpile also supports advanced backend such as memcached or Redis:\r\nhttps://dogpilecache.readthedocs.org/en/latest/api.html#module-dogpile.cache.backends.memory\r\nUsing one of them would probably improve the performances. Please note that Discourse uses a Redis cache: http://www.discourse.org/faq/#tech\r\n\r\nBy the way the configuration of dogpile is at the moment hardcoded (even though I have added it in common.ini.in as well). Using the config files would indeed make sense but I was wondering if would use those ini file or another system such as yaml files.\r\n\r\nNo test is provided. Not sure it is easy to test if the cache works as expected. At least we could for instance if the attributes values of a WP are unchanged after 2 requests whereas the value in the DB has actually changed? We would need also to test the invalidation of the cache when a new version of the document is created (not available yet).\r\n\r\nRelated to #6 "},"comment":{"url":"https://api.github.com/repos/c2corg/v6_api/issues/comments/141996462","html_url":"https://github.com/c2corg/v6_api/pull/15#issuecomment-141996462","issue_url":"https://api.github.com/repos/c2corg/v6_api/issues/15","id":141996462,"user":{"login":"elemoine","id":76594,"avatar_url":"https://avatars.githubusercontent.com/u/76594?v=3","gravatar_id":"","url":"https://api.github.com/users/elemoine","html_url":"https://github.com/elemoine","followers_url":"https://api.github.com/users/elemoine/followers","following_url":"https://api.github.com/users/elemoine/following{/other_user}","gists_url":"https://api.github.com/users/elemoine/gists{/gist_id}","starred_url":"https://api.github.com/users/elemoine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elemoine/subscriptions","organizations_url":"https://api.github.com/users/elemoine/orgs","repos_url":"https://api.github.com/users/elemoine/repos","events_url":"https://api.github.com/users/elemoine/events{/privacy}","received_events_url":"https://api.github.com/users/elemoine/received_events","type":"User","site_admin":false},"created_at":"2015-09-21T14:18:48Z","updated_at":"2015-09-21T14:18:48Z","body":"> By setting a fixed max_age don't we risk that a browser is using an old version of a document even though a newer is available? Wouldn't it make more sense to use etag (e.g. the version number) and/or last-modified?\r\n\r\nYes, maybe. Cliquet uses Etag. See http://cliquet.readthedocs.org/en/latest/api/timestamps.html. They also rely on Etag to avoid race conditions, which may be relevant to our project as well.\r\n\r\nBut note that the `set_common_headers` function, which is the one setting `max_age`, is not currently used. I think it should be removed."}}