{"id":538,"date":"2014-06-05T23:11:00","date_gmt":"2014-06-05T14:11:00","guid":{"rendered":"http:\/\/tech.akat.info\/?p=538"},"modified":"2015-01-11T00:45:44","modified_gmt":"2015-01-10T15:45:44","slug":"nginx-expires","status":"publish","type":"post","link":"https:\/\/tech.akat.info\/?p=538","title":{"rendered":"nginx-expires-"},"content":{"rendered":"<h1>expires\u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6<\/h1>\n<p>\u201cExpires\u201d\u3068\u201cCache-Control\u201d\u30d8\u30c3\u30c0\u3092\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u3059\u308b<\/p>\n<h2>Expires\u3068Cache-Control\u3068\u306f<\/h2>\n<p>Expires\uff1a\u30a8\u30f3\u30c6\u30a3\u30c6\u30a3\u30d8\u30c3\u30c0\u3002\u30ad\u30e3\u30c3\u30b7\u30e5\u30b5\u30fc\u30d0\u304c\u3053\u306e\u30d8\u30c3\u30c0\u3092\u542b\u3080\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u53d7\u3051\u53d6\u308b\u3068\u3001\u6307\u5b9a\u3055\u308c\u305f\u65e5\u6642\u307e\u3067\u30b3\u30d4\u30fc\u3092\u4fdd\u5b58\u3057\u3066\u30ea\u30af\u30a8\u30b9\u30c8\u306b\u306f\u30ad\u30e3\u30c3\u30b7\u30e5\u3067\u5fdc\u3048\u308b\u3088\u3046\u306b\u306a\u308b<br \/>\nCache-Control\uff1a\u4e00\u822c\u30d8\u30c3\u30c0\u3002max-age\u306f<br \/>\n\u901a\u5e38\u3001\u3053\u308c\u3089\u306e\u30d8\u30c3\u30c0\u304c\u540c\u6642\u306b\u8a2d\u5b9a\u3055\u308c\u305f\u5834\u5408\u306f<br \/>\nHTTP\/1.1\u30ad\u30e3\u30c3\u30b7\u30e5\u30b5\u30fc\u30d0\u306e\u5834\u5408\u306f\u3001Cache-Control\u306emax-age\u304c\u512a\u5148\u3055\u308c\u308b<br \/>\nHTTP\/1.0\u30ad\u30e3\u30c3\u30b7\u30e5\u30b5\u30fc\u30d0\u306e\u5834\u5408\u306f\u3001Expires\u304c\u512a\u5148\u3055\u308c\u308b<br \/>\n\u307e\u305f\u3053\u306e2\u3064\u306e\u30d8\u30c3\u30c0\u306b\u7d9a\u3044\u3066\u3001Etag(If-None-Match) > LastModified(If-Modified-Since) \u306e\u9806\u756a\u3067\u30ad\u30e3\u30c3\u30b7\u30e5\u304c\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u3055\u308c\u308b<br \/>\n\u307e\u305fEtag\u3068LastModified\u3092\u53d7\u3051\u53d6\u3063\u305f\u5834\u5408\u306f\u3001\u6761\u4ef6\u4ed8\u304d\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u304b\u3089\u9001\u4fe1\u3059\u308b<\/p>\n<h1>\u52d5\u4f5c\u78ba\u8a8d<\/h1>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nroot@hostname:\/usr\/share\/nginx\/www# wget -d http:\/\/www5d.biglobe.ne.jp\/~marywool\/contents\/2015_nenga\/nenga_sheep_006.jpg\r\nroot@hostname:\/usr\/share\/nginx\/www# mv nenga_sheep_006.jpg sheep.jpg\r\n<\/pre>\n<h1>expires\u306a\u3057<\/h1>\n<h2>Chrome39\u306e\u5834\u5408<\/h2>\n<p>[F5]\u66f4\u65b0\u3057\u3066\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u304b\u3089GET\u30ea\u30af\u30a8\u30b9\u30c8<br \/>\n\u305d\u306e\u969b\u306bCache-Control:max-age=0\u3067\u3042\u308b\u305f\u3081\u3001\u30b5\u30fc\u30d0\u306b\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u306b\u3044\u304f<br \/>\n\u30ea\u30af\u30a8\u30b9\u30c8\u306bIf-Modified-Since\u30d8\u30c3\u30c0\u3082\u542b\u307e\u308c\u3066\u3044\u308b\u305f\u3081<br \/>\n\u30b5\u30fc\u30d0\u306fLast-Moified\u3092\u78ba\u8a8d\u3057\u3001304 Not Modified\u3092\u8fd4\u5374\u3059\u308b<\/p>\n<p>Chrome\u3067\u30d8\u30c3\u30c0\u3092\u78ba\u8a8d\u3059\u308b\u65b9\u6cd5<br \/>\nchrome:\/\/net-internals\/#events<br \/>\n\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u3001[type:URL_REQUEST]\u3067\u30d5\u30a3\u30eb\u30bf\u3059\u308b<br \/>\n<a href=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/06\/2015-01-05_231745.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/06\/2015-01-05_231745.png\" alt=\"2015-01-05_231745\" width=\"1355\" height=\"670\" class=\"alignnone size-full wp-image-1442\" \/><\/a><\/p>\n<p>\u30ea\u30bd\u30fc\u30b9\u3092\u66f4\u65b0\u3057\u305f\u3089\u3001\u3082\u3061\u308d\u3093200\u304c\u8fd4\u5374\u3055\u308c\u308b<br \/>\n<a href=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/06\/2015-01-05_234707.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/06\/2015-01-05_234707.png\" alt=\"2015-01-05_234707\" width=\"1359\" height=\"542\" class=\"alignnone size-full wp-image-1444\" \/><\/a><\/p>\n<h2>IE11\u306e\u5834\u5408<\/h2>\n<p>[F5]\u66f4\u65b0\u3057\u3066\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u304b\u3089GET\u30ea\u30af\u30a8\u30b9\u30c8<br \/>\nChrome\u3068\u9055\u3044\u3001\u6761\u4ef6\u4ed8\u304d\u30ea\u30af\u30a8\u30b9\u30c8(If-Modified-Since)\u3092\u51fa\u3057\u3066\u3044\u306a\u3044\u305f\u3081<br \/>\n\u30b5\u30fc\u30d0\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3001200\u304c\u8fd4\u5374\u3055\u308c\u308b<\/p>\n<p>[F12]\u3067\u958b\u767a\u8005\u30c4\u30fc\u30eb\u304c\u8d77\u52d5\u3059\u308b<br \/>\n<a href=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/06\/2015-01-05_232618.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/06\/2015-01-05_232618.png\" alt=\"2015-01-05_232618\" width=\"1177\" height=\"715\" class=\"alignnone size-full wp-image-1443\" \/><\/a><\/p>\n<h2>\u30ea\u30d0\u30fc\u30b9\u30d7\u30ed\u30ad\u30b7\u3042\u308a<\/h2>\n<p>nginx\u3067\u30ea\u30d0\u30fc\u30b9\u30d7\u30ed\u30ad\u30b7\uff0b\u30ad\u30e3\u30c3\u30b7\u30e5\u30b5\u30fc\u30d0\u3092\u69cb\u7bc9<\/p>\n<pre class=\"brush: plain; title: \u30ea\u30d0\u30fc\u30b9\u30d7\u30ed\u30ad\u30b7\u8a2d\u5b9a; notranslate\" title=\"\u30ea\u30d0\u30fc\u30b9\u30d7\u30ed\u30ad\u30b7\u8a2d\u5b9a\">\r\n&#x5B;root@ip-10-10-10-5 ec2-user]# cat \/etc\/nginx\/nginx.conf \r\n...\r\nhttp {\r\n    proxy_buffering on;\r\n    proxy_cache_path \/var\/cache\/web\/nginx_cache levels=1:2 keys_zone=cachezone:256m max_size=256m inactive=5d;\r\n    proxy_temp_path  \/var\/cache\/web\/nginx_tmp;\r\n    proxy_buffers 200 8k;\r\n...\r\n    server {\r\n        listen       80;\r\n        server_name  54.64.246.142;\r\n        root         \/usr\/share\/nginx\/html;\r\n        location \/ {\r\n                proxy_cache cachezone;\r\n                proxy_cache_valid  200 302 60m;\r\n                proxy_pass http:\/\/49.212.204.46\/;\r\n        }\r\n...\r\n<\/pre>\n<p>\u7d50\u679c\u3068\u3057\u3066\u306fexpires\u306e\u610f\u5473\u3092\u611f\u3058\u308b\u3053\u3068\u304c\u3067\u304d\u306a\u304b\u3063\u305f<br \/>\n49.212.204.46\u306b\u3066expires\u3092\u8a2d\u5b9a\u3057\u3066\u3044\u3088\u3046\u304c\u3001\u3057\u3066\u3044\u307e\u3044\u304c<br \/>\n\u6700\u521d\u306e\u30a2\u30af\u30bb\u30b9\u3068\u30ad\u30e3\u30c3\u30b7\u30e5\u304c\u5207\u308c\u305f\u30bf\u30a4\u30df\u30f3\u30b0\u9664\u304d\u3059\u3079\u306654.64.246.142\u304c200\u304b304\u3092\u8fd4\u5374\u3059\u308b<br \/>\n<a href=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/06\/2015-01-08_012135.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/06\/2015-01-08_012135.png\" alt=\"2015-01-08_012135\" width=\"856\" height=\"549\" class=\"alignnone size-full wp-image-1450\" \/><\/a><\/p>\n<h1>expires\u3042\u308a<\/h1>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nlocation ~ .*\\.jpg {\r\n        expires 10d;\r\n}\r\n<\/pre>\n<h2>Chrome39\u306e\u5834\u5408<\/h2>\n<p>\u3055\u304d\u307b\u3069\u3068\u5909\u308f\u3089\u306a\u3044<br \/>\n\u65b0\u3057\u304fCache-Control\u30fbExpires\u30d8\u30c3\u30c0\u304c\u8ffd\u52a0\u3055\u308c\u308b\u304c<br \/>\nIf-Modified-Since\u30d8\u30c3\u30c0\u3068Last-Moified\u306e\u95a2\u4fc2\u3067304\u3092\u8fd4\u5374\u3059\u308b\u304b\u3001200\u3092\u8fd4\u5374\u3059\u308b\u304b\u304c\u6c7a\u307e\u308b<\/p>\n<p><a href=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/06\/2015-01-06_000833.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/06\/2015-01-06_000833.png\" alt=\"2015-01-06_000833\" width=\"1349\" height=\"633\" class=\"alignnone size-full wp-image-1440\" \/><\/a><\/p>\n<h2>IE11\u306e\u5834\u5408<\/h2>\n<p>\u3055\u304d\u307b\u3069\u3068\u5909\u308f\u3089\u306a\u3044<br \/>\n\u65b0\u3057\u304fCache-Control\u30fbExpires\u30d8\u30c3\u30c0\u304c\u8ffd\u52a0\u3055\u308c\u308b\u304c\u3001\u5e38\u306b200\u3092\u8fd4\u5374\u3059\u308b<\/p>\n<p><a href=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/06\/2015-01-06_001648.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/06\/2015-01-06_001648.png\" alt=\"2015-01-06_001648\" width=\"1159\" height=\"708\" class=\"alignnone size-full wp-image-1439\" \/><\/a><\/p>\n<h2>\u30d7\u30ed\u30ad\u30b7\u5229\u7528\u6642<\/h2>\n<p>squid\u3067\u30d7\u30ed\u30ad\u30b7\u3092\u69cb\u7bc9\u3057\u305f<br \/>\nChrome\u3067\u30d7\u30ed\u30ad\u30b7\u3092\u5229\u7528\u3057\u3066\u307f\u305f\u304c\u3001[F5]\u3067\u66f4\u65b0\u3057\u305f\u6642\u306f304\u3001[ctl]+[F5]\u3060\u3068200\u3067\u3042\u308a\u3001\u7279\u306b\u5909\u5316\u306f\u306a\u304b\u3063\u305f<\/p>\n<pre class=\"brush: plain; title: \u30d7\u30ed\u30ad\u30b7\u8a2d\u5b9a; notranslate\" title=\"\u30d7\u30ed\u30ad\u30b7\u8a2d\u5b9a\">\r\n&#x5B;root@ip-10-10-10-5 ec2-user]# yum install squid\r\n&#x5B;root@ip-10-10-10-5 ec2-user]# vi \/etc\/squid\/squid.conf\r\n...\r\nacl localnet src x.x.x.x\/32 # \u30d7\u30ed\u30ad\u30b7\u3092\u5229\u7528\u3059\u308b\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306eIP\u3092localnet\u306b\u8ffd\u52a0\u3057\u305f\r\nhttp_access allow localhost # localnet\u3092\u8a31\u53ef\u3059\u308b\u3001deny\u3088\u308a\u3082\u4e0a\u306b\u8a18\u8f09\u3059\u308b\u3053\u3068\r\nhttp_access deny manager\r\n### cache ###\r\ncache_mem 16 MB\r\ncache_dir ufs \/var\/spool\/squid 100 16 256\r\nrefresh_pattern -i \\.jpg$ 1440 20% 10080\r\n...\r\n&#x5B;root@ip-10-10-10-5 ec2-user]# \/etc\/init.d\/squid start\r\nStarting squid: .                                          &#x5B;  OK  ]\r\n<\/pre>\n<p>[F5]\u3067\u66f4\u65b0\u6642<br \/>\n<a href=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/06\/2015-01-09_002601.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/06\/2015-01-09_002601.png\" alt=\"2015-01-09_002601\" width=\"1341\" height=\"684\" class=\"alignnone size-full wp-image-1467\" \/><\/a><\/p>\n<p>[ctl]+[F5]\u3067\u66f4\u65b0\u6642<br \/>\n<a href=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/06\/2015-01-09_004839.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/06\/2015-01-09_004839.png\" alt=\"2015-01-09_004839\" width=\"1349\" height=\"675\" class=\"alignnone size-full wp-image-1468\" \/><\/a><\/p>\n<h1>\u53c2\u8003URL<\/h1>\n<p>HttpHeadersModuleJa<br \/>\nhttp:\/\/wiki.nginx.org\/HttpHeadersModuleJa<\/p>\n","protected":false},"excerpt":{"rendered":"<p>expires\u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6 \u201cExpires\u201d\u3068\u201cCache-Control\u201d\u30d8\u30c3\u30c0\u3092\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u3059\u308b Expires\u3068Cache-Control\u3068\u306f Expires\uff1a\u30a8\u30f3\u30c6\u30a3\u30c6\u30a3\u30d8\u30c3\u30c0\u3002\u30ad\u30e3\u30c3\u30b7\u30e5\u30b5\u30fc\u30d0\u304c\u3053\u306e\u30d8\u30c3\u30c0\u3092 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[18],"tags":[],"_links":{"self":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts\/538"}],"collection":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=538"}],"version-history":[{"count":22,"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts\/538\/revisions"}],"predecessor-version":[{"id":1471,"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts\/538\/revisions\/1471"}],"wp:attachment":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=538"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=538"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=538"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}