{"action":"closed","number":182,"pull_request":{"url":"https://api.github.com/repos/dpla/automation/pulls/182","id":71101879,"html_url":"https://github.com/dpla/automation/pull/182","diff_url":"https://github.com/dpla/automation/pull/182.diff","patch_url":"https://github.com/dpla/automation/pull/182.patch","issue_url":"https://api.github.com/repos/dpla/automation/issues/182","number":182,"state":"closed","locked":false,"title":"Improve NGINX cache configuration","user":{"login":"markbreedlove","id":5550828,"avatar_url":"https://avatars.githubusercontent.com/u/5550828?v=3","gravatar_id":"","url":"https://api.github.com/users/markbreedlove","html_url":"https://github.com/markbreedlove","followers_url":"https://api.github.com/users/markbreedlove/followers","following_url":"https://api.github.com/users/markbreedlove/following{/other_user}","gists_url":"https://api.github.com/users/markbreedlove/gists{/gist_id}","starred_url":"https://api.github.com/users/markbreedlove/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markbreedlove/subscriptions","organizations_url":"https://api.github.com/users/markbreedlove/orgs","repos_url":"https://api.github.com/users/markbreedlove/repos","events_url":"https://api.github.com/users/markbreedlove/events{/privacy}","received_events_url":"https://api.github.com/users/markbreedlove/received_events","type":"User","site_admin":false},"body":"The goal of these changes was originally to cache `/thumb` resources, but it became apparent that we could do better in caching overall.\r\n\r\nWith this commit, and some work on the frontend app, it will be possible some day to forego the cache-purging that we usually do after a deployment.\r\n\r\n* Reduce the number of proxy_cache_valid directives.\r\n\r\n* Express 'expires' with date units.\r\n\r\n* Remove redundant proxy_cache_valid directives. There was some variation, but not enough for it to be perpetuated.\r\n\r\n* Rename shared memory zone from \"staticfilecache\" to \"main_cache\" because it's not simply a static file cache.\r\n\r\n* Add \"inactive\" parameter to proxy_cache_path, which was defaulting to 10 minutes.\r\n\r\n* Add note about proxy_cache_revalidate (NGINX sends If-Modified-Since to origin).  We can't use it because we're still on Ubuntu 12.04LTS, with NGINX 1.1.\r\n\r\n* Add proxy_cache_lock so concurrent requests don't get sent to origin server for the same thing.\r\n\r\n* Change some comments.\r\n\r\n* Change proxy_cache_use_stale for /thumbp location. Move on to next origin server in the event of connection error or timeout via proxy_next_upstream, but deliver stale file for a 500 or 503, assuming the other server won't respond any better.\r\n\r\n* Add Cache-Control and X-Cache-Status headers to individual locations\r\n\r\n* Hide X-Powered-By header.\r\n\r\n* Shorten expiration time of Exhibitions assets.\r\n\r\n* Enable caching of Primary Source Sets assets.\r\n\r\n* Have the cache store 301 responses in a number of locations.\r\n\r\n* Remove test.php and phpinfo.php locations within /info location.\r\n\r\n* Make proxy_cache_key consistent across configuration.\r\n\r\n* Remove ability to defeat caching by setting Cache-Bypass header.\r\n\r\n* Simplify use of proxy_cache_bypass and proxy_no_cache.\r\n\r\nIt would be great to extend the expiration of frontend assets, but there are still some that the `frontend` app does not seem to compile and assign cache-extending names. The expiration for assets in the frontend therefore is one minute.\r\n\r\nWordpress assets in wp-includes and in plugins are versioned, but those in the berkman theme are not. No image assets are versioned. The expiration for the wordpress site for anonymous users (who do not have the relevant cookies) is one minute for most resources and one month for the versioned assets.\r\n\r\nThese changes don't fix the development environment's longstanding asset-pipeline problems. The frontend has uncompiled assets that shouldn't be cached for long periods. The deployments still clear the proxy cache, so this is OK for the meantime. In the future, we need to clear the cache conditionally: clear it after a deployment only in the development environment, and let asset versioning do the job in production.\r\n\r\nThe `_dpla_no_cache` cookie for the frontend should still be recognized because it still applies to admin requests. For caching to be optimal, the frontend app needs to be modified to set the `_dpla_no_cache` header only when necessary, not with every single request. It should only be set when an admin logs in or out. The `/saved` and `/users` locations have caching disabled for regular users who are logged in.\r\n\r\nWe don't cache the frontend app's HTML because it's too problematic for loggged-in users and the app library. Applications should be in charge of setting good cache headers for authenticated and unauthenticated requests, and it's bad to second-guess them in the proxy configuration.\r\n","created_at":"2016-05-23T18:53:07Z","updated_at":"2016-05-24T21:41:04Z","closed_at":"2016-05-24T21:41:04Z","merged_at":"2016-05-24T21:41:04Z","merge_commit_sha":"14036430ef9b601f920bf7adc0964b4927a3d594","assignee":{"login":"no-reply","id":1361776,"avatar_url":"https://avatars.githubusercontent.com/u/1361776?v=3","gravatar_id":"","url":"https://api.github.com/users/no-reply","html_url":"https://github.com/no-reply","followers_url":"https://api.github.com/users/no-reply/followers","following_url":"https://api.github.com/users/no-reply/following{/other_user}","gists_url":"https://api.github.com/users/no-reply/gists{/gist_id}","starred_url":"https://api.github.com/users/no-reply/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/no-reply/subscriptions","organizations_url":"https://api.github.com/users/no-reply/orgs","repos_url":"https://api.github.com/users/no-reply/repos","events_url":"https://api.github.com/users/no-reply/events{/privacy}","received_events_url":"https://api.github.com/users/no-reply/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/dpla/automation/pulls/182/commits","review_comments_url":"https://api.github.com/repos/dpla/automation/pulls/182/comments","review_comment_url":"https://api.github.com/repos/dpla/automation/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dpla/automation/issues/182/comments","statuses_url":"https://api.github.com/repos/dpla/automation/statuses/3152dd701b957a7d981ad27a826b673f1af74b25","head":{"label":"dpla:fix/tidy-up-cache-directives","ref":"fix/tidy-up-cache-directives","sha":"3152dd701b957a7d981ad27a826b673f1af74b25","user":{"login":"dpla","id":1252916,"avatar_url":"https://avatars.githubusercontent.com/u/1252916?v=3","gravatar_id":"","url":"https://api.github.com/users/dpla","html_url":"https://github.com/dpla","followers_url":"https://api.github.com/users/dpla/followers","following_url":"https://api.github.com/users/dpla/following{/other_user}","gists_url":"https://api.github.com/users/dpla/gists{/gist_id}","starred_url":"https://api.github.com/users/dpla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpla/subscriptions","organizations_url":"https://api.github.com/users/dpla/orgs","repos_url":"https://api.github.com/users/dpla/repos","events_url":"https://api.github.com/users/dpla/events{/privacy}","received_events_url":"https://api.github.com/users/dpla/received_events","type":"Organization","site_admin":false},"repo":{"id":20342234,"name":"automation","full_name":"dpla/automation","owner":{"login":"dpla","id":1252916,"avatar_url":"https://avatars.githubusercontent.com/u/1252916?v=3","gravatar_id":"","url":"https://api.github.com/users/dpla","html_url":"https://github.com/dpla","followers_url":"https://api.github.com/users/dpla/followers","following_url":"https://api.github.com/users/dpla/following{/other_user}","gists_url":"https://api.github.com/users/dpla/gists{/gist_id}","starred_url":"https://api.github.com/users/dpla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpla/subscriptions","organizations_url":"https://api.github.com/users/dpla/orgs","repos_url":"https://api.github.com/users/dpla/repos","events_url":"https://api.github.com/users/dpla/events{/privacy}","received_events_url":"https://api.github.com/users/dpla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dpla/automation","description":"For automated configuration management of DPLA servers","fork":false,"url":"https://api.github.com/repos/dpla/automation","forks_url":"https://api.github.com/repos/dpla/automation/forks","keys_url":"https://api.github.com/repos/dpla/automation/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dpla/automation/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dpla/automation/teams","hooks_url":"https://api.github.com/repos/dpla/automation/hooks","issue_events_url":"https://api.github.com/repos/dpla/automation/issues/events{/number}","events_url":"https://api.github.com/repos/dpla/automation/events","assignees_url":"https://api.github.com/repos/dpla/automation/assignees{/user}","branches_url":"https://api.github.com/repos/dpla/automation/branches{/branch}","tags_url":"https://api.github.com/repos/dpla/automation/tags","blobs_url":"https://api.github.com/repos/dpla/automation/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dpla/automation/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dpla/automation/git/refs{/sha}","trees_url":"https://api.github.com/repos/dpla/automation/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dpla/automation/statuses/{sha}","languages_url":"https://api.github.com/repos/dpla/automation/languages","stargazers_url":"https://api.github.com/repos/dpla/automation/stargazers","contributors_url":"https://api.github.com/repos/dpla/automation/contributors","subscribers_url":"https://api.github.com/repos/dpla/automation/subscribers","subscription_url":"https://api.github.com/repos/dpla/automation/subscription","commits_url":"https://api.github.com/repos/dpla/automation/commits{/sha}","git_commits_url":"https://api.github.com/repos/dpla/automation/git/commits{/sha}","comments_url":"https://api.github.com/repos/dpla/automation/comments{/number}","issue_comment_url":"https://api.github.com/repos/dpla/automation/issues/comments{/number}","contents_url":"https://api.github.com/repos/dpla/automation/contents/{+path}","compare_url":"https://api.github.com/repos/dpla/automation/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dpla/automation/merges","archive_url":"https://api.github.com/repos/dpla/automation/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dpla/automation/downloads","issues_url":"https://api.github.com/repos/dpla/automation/issues{/number}","pulls_url":"https://api.github.com/repos/dpla/automation/pulls{/number}","milestones_url":"https://api.github.com/repos/dpla/automation/milestones{/number}","notifications_url":"https://api.github.com/repos/dpla/automation/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dpla/automation/labels{/name}","releases_url":"https://api.github.com/repos/dpla/automation/releases{/id}","deployments_url":"https://api.github.com/repos/dpla/automation/deployments","created_at":"2014-05-30T20:56:02Z","updated_at":"2016-02-11T02:10:48Z","pushed_at":"2016-05-24T21:41:04Z","git_url":"git://github.com/dpla/automation.git","ssh_url":"git@github.com:dpla/automation.git","clone_url":"https://github.com/dpla/automation.git","svn_url":"https://github.com/dpla/automation","homepage":null,"size":763,"stargazers_count":6,"watchers_count":6,"language":"Shell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":1,"forks":5,"open_issues":1,"watchers":6,"default_branch":"develop"}},"base":{"label":"dpla:develop","ref":"develop","sha":"b01e48d5cba26bc77fedeec4e029b36584964ceb","user":{"login":"dpla","id":1252916,"avatar_url":"https://avatars.githubusercontent.com/u/1252916?v=3","gravatar_id":"","url":"https://api.github.com/users/dpla","html_url":"https://github.com/dpla","followers_url":"https://api.github.com/users/dpla/followers","following_url":"https://api.github.com/users/dpla/following{/other_user}","gists_url":"https://api.github.com/users/dpla/gists{/gist_id}","starred_url":"https://api.github.com/users/dpla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpla/subscriptions","organizations_url":"https://api.github.com/users/dpla/orgs","repos_url":"https://api.github.com/users/dpla/repos","events_url":"https://api.github.com/users/dpla/events{/privacy}","received_events_url":"https://api.github.com/users/dpla/received_events","type":"Organization","site_admin":false},"repo":{"id":20342234,"name":"automation","full_name":"dpla/automation","owner":{"login":"dpla","id":1252916,"avatar_url":"https://avatars.githubusercontent.com/u/1252916?v=3","gravatar_id":"","url":"https://api.github.com/users/dpla","html_url":"https://github.com/dpla","followers_url":"https://api.github.com/users/dpla/followers","following_url":"https://api.github.com/users/dpla/following{/other_user}","gists_url":"https://api.github.com/users/dpla/gists{/gist_id}","starred_url":"https://api.github.com/users/dpla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpla/subscriptions","organizations_url":"https://api.github.com/users/dpla/orgs","repos_url":"https://api.github.com/users/dpla/repos","events_url":"https://api.github.com/users/dpla/events{/privacy}","received_events_url":"https://api.github.com/users/dpla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dpla/automation","description":"For automated configuration management of DPLA servers","fork":false,"url":"https://api.github.com/repos/dpla/automation","forks_url":"https://api.github.com/repos/dpla/automation/forks","keys_url":"https://api.github.com/repos/dpla/automation/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dpla/automation/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dpla/automation/teams","hooks_url":"https://api.github.com/repos/dpla/automation/hooks","issue_events_url":"https://api.github.com/repos/dpla/automation/issues/events{/number}","events_url":"https://api.github.com/repos/dpla/automation/events","assignees_url":"https://api.github.com/repos/dpla/automation/assignees{/user}","branches_url":"https://api.github.com/repos/dpla/automation/branches{/branch}","tags_url":"https://api.github.com/repos/dpla/automation/tags","blobs_url":"https://api.github.com/repos/dpla/automation/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dpla/automation/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dpla/automation/git/refs{/sha}","trees_url":"https://api.github.com/repos/dpla/automation/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dpla/automation/statuses/{sha}","languages_url":"https://api.github.com/repos/dpla/automation/languages","stargazers_url":"https://api.github.com/repos/dpla/automation/stargazers","contributors_url":"https://api.github.com/repos/dpla/automation/contributors","subscribers_url":"https://api.github.com/repos/dpla/automation/subscribers","subscription_url":"https://api.github.com/repos/dpla/automation/subscription","commits_url":"https://api.github.com/repos/dpla/automation/commits{/sha}","git_commits_url":"https://api.github.com/repos/dpla/automation/git/commits{/sha}","comments_url":"https://api.github.com/repos/dpla/automation/comments{/number}","issue_comment_url":"https://api.github.com/repos/dpla/automation/issues/comments{/number}","contents_url":"https://api.github.com/repos/dpla/automation/contents/{+path}","compare_url":"https://api.github.com/repos/dpla/automation/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dpla/automation/merges","archive_url":"https://api.github.com/repos/dpla/automation/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dpla/automation/downloads","issues_url":"https://api.github.com/repos/dpla/automation/issues{/number}","pulls_url":"https://api.github.com/repos/dpla/automation/pulls{/number}","milestones_url":"https://api.github.com/repos/dpla/automation/milestones{/number}","notifications_url":"https://api.github.com/repos/dpla/automation/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dpla/automation/labels{/name}","releases_url":"https://api.github.com/repos/dpla/automation/releases{/id}","deployments_url":"https://api.github.com/repos/dpla/automation/deployments","created_at":"2014-05-30T20:56:02Z","updated_at":"2016-02-11T02:10:48Z","pushed_at":"2016-05-24T21:41:04Z","git_url":"git://github.com/dpla/automation.git","ssh_url":"git@github.com:dpla/automation.git","clone_url":"https://github.com/dpla/automation.git","svn_url":"https://github.com/dpla/automation","homepage":null,"size":763,"stargazers_count":6,"watchers_count":6,"language":"Shell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":1,"forks":5,"open_issues":1,"watchers":6,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/dpla/automation/pulls/182"},"html":{"href":"https://github.com/dpla/automation/pull/182"},"issue":{"href":"https://api.github.com/repos/dpla/automation/issues/182"},"comments":{"href":"https://api.github.com/repos/dpla/automation/issues/182/comments"},"review_comments":{"href":"https://api.github.com/repos/dpla/automation/pulls/182/comments"},"review_comment":{"href":"https://api.github.com/repos/dpla/automation/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dpla/automation/pulls/182/commits"},"statuses":{"href":"https://api.github.com/repos/dpla/automation/statuses/3152dd701b957a7d981ad27a826b673f1af74b25"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"no-reply","id":1361776,"avatar_url":"https://avatars.githubusercontent.com/u/1361776?v=3","gravatar_id":"","url":"https://api.github.com/users/no-reply","html_url":"https://github.com/no-reply","followers_url":"https://api.github.com/users/no-reply/followers","following_url":"https://api.github.com/users/no-reply/following{/other_user}","gists_url":"https://api.github.com/users/no-reply/gists{/gist_id}","starred_url":"https://api.github.com/users/no-reply/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/no-reply/subscriptions","organizations_url":"https://api.github.com/users/no-reply/orgs","repos_url":"https://api.github.com/users/no-reply/repos","events_url":"https://api.github.com/users/no-reply/events{/privacy}","received_events_url":"https://api.github.com/users/no-reply/received_events","type":"User","site_admin":false},"comments":2,"review_comments":0,"commits":1,"additions":140,"deletions":87,"changed_files":2}}
{"actor":{"display_login":"no-reply"}}