{"action":"created","issue":{"url":"https://api.github.com/repos/divio/django-cms/issues/4310","repository_url":"https://api.github.com/repos/divio/django-cms","labels_url":"https://api.github.com/repos/divio/django-cms/issues/4310/labels{/name}","comments_url":"https://api.github.com/repos/divio/django-cms/issues/4310/comments","events_url":"https://api.github.com/repos/divio/django-cms/issues/4310/events","html_url":"https://github.com/divio/django-cms/issues/4310","id":97012952,"number":4310,"title":"Static placeholder triggering a cache set on every request or always part of the SQL queries","user":{"login":"marksweb","id":1461191,"avatar_url":"https://avatars2.githubusercontent.com/u/1461191?v=3","gravatar_id":"","url":"https://api.github.com/users/marksweb","html_url":"https://github.com/marksweb","followers_url":"https://api.github.com/users/marksweb/followers","following_url":"https://api.github.com/users/marksweb/following{/other_user}","gists_url":"https://api.github.com/users/marksweb/gists{/gist_id}","starred_url":"https://api.github.com/users/marksweb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marksweb/subscriptions","organizations_url":"https://api.github.com/users/marksweb/orgs","repos_url":"https://api.github.com/users/marksweb/repos","events_url":"https://api.github.com/users/marksweb/events{/privacy}","received_events_url":"https://api.github.com/users/marksweb/received_events","type":"User","site_admin":false},"labels":[{"id":155469099,"url":"https://api.github.com/repos/divio/django-cms/labels/status:%20accepted","name":"status: accepted","color":"0052cc","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/divio/django-cms/milestones/41","html_url":"https://github.com/divio/django-cms/milestone/41","labels_url":"https://api.github.com/repos/divio/django-cms/milestones/41/labels","id":1363750,"number":41,"title":"Clean up issues & pull requests","description":"We're aiming to tidy up outstanding issues in the project, by assessing open tickets, and closing any that seem no longer applicable.\r\n\r\nAfter the due date (30th November 2015) has passed, any tickets that have not progressed  (have received no comments or updates) will be removed without further notice.","creator":{"login":"evildmp","id":86222,"avatar_url":"https://avatars0.githubusercontent.com/u/86222?v=3","gravatar_id":"","url":"https://api.github.com/users/evildmp","html_url":"https://github.com/evildmp","followers_url":"https://api.github.com/users/evildmp/followers","following_url":"https://api.github.com/users/evildmp/following{/other_user}","gists_url":"https://api.github.com/users/evildmp/gists{/gist_id}","starred_url":"https://api.github.com/users/evildmp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evildmp/subscriptions","organizations_url":"https://api.github.com/users/evildmp/orgs","repos_url":"https://api.github.com/users/evildmp/repos","events_url":"https://api.github.com/users/evildmp/events{/privacy}","received_events_url":"https://api.github.com/users/evildmp/received_events","type":"User","site_admin":false},"open_issues":47,"closed_issues":75,"state":"open","created_at":"2015-10-19T11:35:27Z","updated_at":"2017-05-08T23:21:29Z","due_on":null,"closed_at":null},"comments":6,"created_at":"2015-07-24T09:31:17Z","updated_at":"2017-05-09T00:04:56Z","closed_at":null,"body":"I've got a static_placeholder in my base template for the footer of the site.\n\n```\n            <div class=\"wrapper\"><!-- Start wrapper -->\n\n                {% block base-static-footer %}\n                    {% static_placeholder \"footer\" site %}\n                {% endblock base-static-footer %}\n\n            </div><!-- End wrapper -->\n```\n\nThis testing is happening on my local machine running memcache, in debug mode, without being logged in. Cache settings;\n\n``` python\nCMS_PAGE_CACHE = False\nCMS_PLACEHOLDER_CACHE = True\nCMS_PLUGIN_CACHE = True\n\n# -- CMS CACHE DEFAULTS INCREASED -- #\nCMS_CACHE_DURATIONS = {\n    'menus': 3600,  # default: 3600\n    'content': 3600,  # default: 60\n    'permissions': 3600,  # default: 3600\n}\n```\n\nAs I understand it, all static placeholders are cached, and I've had my breakpoints in PyCharm to watch what's happening with all the placeholders on my homepage & it looks as though the footer calls the `cache.set` as expected.\n\nHowever if you monitor the debug toolbar on each page refresh, there are 2 cache sets, one comes from the static footer, the other from the cache version. \n\nNow step forward 24 hours & I'm seeing between 54 & 15 SQL queries per request, and in each instance, the static footer is part of the database hits, so today I'm not even seeing the cache sets that I was yesterday (no code/config changes in that time). SQL query;\n\n```\nSELECT ••• FROM `cms_staticplaceholder` WHERE (`cms_staticplaceholder`.`code` = 'footer' AND `cms_staticplaceholder`.`site_id` = 1) LIMIT 21\n```\n\nThe end of the stack on that query is;\n\n```\n/Users/mwalker/Sites/proj/lib/python2.7/site-packages/cms/templatetags/cms_tags.py in render_tag(670)\n  rendered_contents = nodelist.render(context)\n/Users/mwalker/Sites/proj/lib/python2.7/site-packages/classytags/core.py in render(106)\n  return self.render_tag(context, **kwargs)\n/Users/mwalker/Sites/proj/lib/python2.7/site-packages/classytags/helpers.py in render_tag(87)\n  output = render_to_string(template, data)\n/Users/mwalker/Sites/proj/lib/python2.7/site-packages/classytags/core.py in render(106)\n  return self.render_tag(context, **kwargs)\n/Users/mwalker/Sites/proj/lib/python2.7/site-packages/cms/templatetags/cms_tags.py in render_tag(1121)\n  'creation_method': StaticPlaceholder.CREATION_BY_TEMPLATE})\n```\n\nAlso, I'm seeing queries relating to other apps which sit on other pages via an app hook, but show as coming from `{% static_placeholder \"footer\" site %}` when you inspect the query in the debug toolbar. In this instance, the body attribute of the `LatestNews` model is a `PlaceholderField`;\n\n```\nSELECT COUNT(*) FROM `news_latestnews` WHERE `news_latestnews`.`body_id` = 50\n```\n\nIs that query triggered because the ID of `LatestNews.body` (PlaceholderField) could potentially be 50? It seems an odd query, given the template tag is `static_placeholder` and it might have an ID of 50, but then why does it query my app's placeholder field?\n\nAnd if it helps, the bottom end of the stack on that query is;\n\n```\n/Users/mwalker/Sites/proj/lib/python2.7/site-packages/cms/templatetags/cms_tags.py in render_tag(1137)\n  content = render_placeholder(placeholder, context, name_fallback=code, default=nodelist)\n/Users/mwalker/Sites/proj/lib/python2.7/site-packages/cms/plugin_rendering.py in render_placeholder(115)\n  if placeholder.has_change_permission(request) or not placeholder.cache_placeholder:\n/Users/mwalker/Sites/proj/lib/python2.7/site-packages/cms/models/placeholdermodel.py in has_change_permission(118)\n  return self._get_permission(request, 'change')\n/Users/mwalker/Sites/proj/lib/python2.7/site-packages/cms/models/placeholdermodel.py in _get_permission(107)\n  for obj in self._get_attached_objects():\n/Users/mwalker/Sites/proj/lib/python2.7/site-packages/cms/models/placeholdermodel.py in _get_attached_objects(227)\n  return [obj for field in self._get_attached_fields()\n/Users/mwalker/Sites/proj/lib/python2.7/site-packages/cms/models/placeholdermodel.py in _get_attached_fields(157)\n  if field.count():\n```\n"},"comment":{"url":"https://api.github.com/repos/divio/django-cms/issues/comments/300024290","html_url":"https://github.com/divio/django-cms/issues/4310#issuecomment-300024290","issue_url":"https://api.github.com/repos/divio/django-cms/issues/4310","id":300024290,"user":{"login":"mkoistinen","id":615759,"avatar_url":"https://avatars0.githubusercontent.com/u/615759?v=3","gravatar_id":"","url":"https://api.github.com/users/mkoistinen","html_url":"https://github.com/mkoistinen","followers_url":"https://api.github.com/users/mkoistinen/followers","following_url":"https://api.github.com/users/mkoistinen/following{/other_user}","gists_url":"https://api.github.com/users/mkoistinen/gists{/gist_id}","starred_url":"https://api.github.com/users/mkoistinen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkoistinen/subscriptions","organizations_url":"https://api.github.com/users/mkoistinen/orgs","repos_url":"https://api.github.com/users/mkoistinen/repos","events_url":"https://api.github.com/users/mkoistinen/events{/privacy}","received_events_url":"https://api.github.com/users/mkoistinen/received_events","type":"User","site_admin":false},"created_at":"2017-05-09T00:04:56Z","updated_at":"2017-05-09T00:04:56Z","body":"Hi @marksweb I'm not in a position to spend any time on this for the foreseeable future. Sorry. Perhaps you can add some test cases, etc., to your monkey-patches and make it a pull request?"}}
{"actor":{"display_login":"mkoistinen"}}