{"id":721,"date":"2017-05-12T14:07:27","date_gmt":"2017-05-12T05:07:27","guid":{"rendered":"https:\/\/clouds.tokyo\/blog\/?p=721"},"modified":"2017-05-26T16:35:20","modified_gmt":"2017-05-26T07:35:20","slug":"php_cache","status":"publish","type":"post","link":"https:\/\/clouds.tokyo\/blog\/php_cache\/","title":{"rendered":"\u3010PHP\u3011Last-Modified\u30d8\u30c3\u30c0\u306b\u3088\u308b\u9759\u7684\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u5236\u5fa1"},"content":{"rendered":"<p>\u753b\u50cf\u306a\u3069\u306e\u9759\u7684\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u76f4\u63a5\u30a2\u30af\u30bb\u30b9\u3057\u305f\u5834\u5408\u306f<br \/>\n\u30d6\u30e9\u30a6\u30b6\u304c\u81ea\u52d5\u7684\u306b\u30ad\u30e3\u30c3\u30b7\u30e5\u5236\u5fa1\u3092\u884c\u3063\u3066\u304f\u308c\u307e\u3059\u304c\u3001<br \/>\nPHP\u3067\u9759\u7684\u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u8fd4\u3059\u3088\u3046\u306a\u51e6\u7406\u3092\u884c\u3063\u3066\u3044\u308b\u5834\u5408\u306b\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u5229\u7528\u3059\u308b\u306b\u306f<br \/>\nLast-Modified\u30d8\u30c3\u30c0\u3092\u4f7f\u3063\u3066\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u5236\u5fa1\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u3001PHP\u3067\u30d5\u30a1\u30a4\u30eb\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3055\u305b\u308b\u969b\u306b<br \/>\nfilemtime\u95a2\u6570\u3067\u30d5\u30a1\u30a4\u30eb\u306e\u66f4\u65b0\u65e5\u6642\u3092\u53d6\u5f97\u3057\u3066Last-Modified\u30d8\u30c3\u30c0\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre>\r\nheader('Last-Modified: filemtime('\u30d5\u30a1\u30a4\u30eb\u306e\u30d1\u30b9'));\r\n<\/pre>\n<p>\u3055\u3089\u306b\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u6b8b\u3059\u305f\u3081\u306e\u30d8\u30c3\u30c0\u3082\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre>\r\nheader('Pragma: cache');\r\nheader(\"Cache-Control: max-age=\" . (60 * 60 * 24 * 30)); \/\/ \u6709\u52b9\u671f\u959330\u65e5\u306e\u4f8b\r\n<\/pre>\n<p>\u305d\u3046\u3059\u308b\u3068\u3001\u6b21\u306b\u540c\u3058\u30d5\u30a1\u30a4\u30eb\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3088\u3046\u3068\u3057\u305f\u969b\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u30d8\u30c3\u30c0\u306e\u4e2d\u306b<\/p>\n<pre>\r\nHTTP_IF_MODIFIED_SINCE\r\n<\/pre>\n<p>\u3068\u3044\u3046\u30d8\u30c3\u30c0\u304c\u8ffd\u52a0\u3055\u308c\u3001\u30d5\u30a1\u30a4\u30eb\u306e\u66f4\u65b0\u65e5\u6642\u304c\u5165\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3067\u3059\u306e\u3067\u3001\u3053\u306e\u30d8\u30c3\u30c0\u306e\u6709\u7121\u3092\u8abf\u3079\u3001\u30d5\u30a1\u30a4\u30eb\u306e\u66f4\u65b0\u65e5\u6642\u3068\u6bd4\u8f03\u3059\u308b\u3053\u3068\u3067<br \/>\n\u30d5\u30a1\u30a4\u30eb\u3092\u8fd4\u3059\u304b\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u8fd4\u3059\u304b\u3092\u5224\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre>\r\n$filelastmodified = filemtime('\u30d5\u30a1\u30a4\u30eb\u306e\u30d1\u30b9');\r\nif(isset($_SERVER[\"HTTP_IF_MODIFIED_SINCE\"])){\r\n  $headerlastmodified = $_SERVER[\"HTTP_IF_MODIFIED_SINCE\"];\r\n  if(strtotime($headerlastmodified == strtotime($filelastmodified)){\r\n    \/\/ \u66f4\u65b0\u65e5\u304c\u4e00\u81f4\u3057\u305f\u306e\u3067\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u8fd4\u3059\r\n    \/\/ \uff08\u6b63\u3057\u304f\u306f\u30ec\u30b9\u30dd\u30f3\u30b9\u30b3\u30fc\u30c9304\u3092\u8fd4\u3059\uff09\r\n  }\r\n  else {\r\n    \/\/ \u30d5\u30a1\u30a4\u30eb\u3092\u8fd4\u3059\r\n  }\r\n}\r\n<\/pre>\n<p>\u30ec\u30b9\u30dd\u30f3\u30b9\u30b3\u30fc\u30c9304\u3092\u8fd4\u3059\u51e6\u7406\u306f\u4e0b\u8a18\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n<pre>\r\nheader(\"HTTP\/1.1 304 image not modified\");\r\nheader('Pragma: cache');\r\nheader(\"Cache-Control: max-age=\" . (60 * 60 * 24 * 30));\r\n<\/pre>\n<p>\u3061\u306a\u307f\u306b\u3001Etag\u3068\u3044\u3046\u30d8\u30c3\u30c0\u3092\u4f7f\u3063\u3066\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u5236\u5fa1\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u304c<br \/>\nEtag\u306f\u3069\u3061\u3089\u304b\u3068\u3044\u3046\u3068\u52d5\u7684\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u3067\u5229\u7528\u3059\u308b\u305f\u3081\u306e\u3082\u306e\u3067\u3059\u3002<br \/>\n\u9759\u7684\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u306b\u3082Etag\u3092\u4f7f\u3063\u305f\u30b5\u30f3\u30d7\u30eb\u304c\u591a\u304f\u307f\u3089\u308c\u308b\u306e\u3067\u3059\u304c<br \/>\nLast-Modified\u30d8\u30c3\u30c0\u3060\u3051\u3067\u5341\u5206\u3060\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u753b\u50cf\u306a\u3069\u306e\u9759\u7684\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u76f4\u63a5\u30a2\u30af\u30bb\u30b9\u3057\u305f\u5834\u5408\u306f \u30d6\u30e9\u30a6\u30b6\u304c\u81ea\u52d5\u7684\u306b\u30ad\u30e3\u30c3\u30b7\u30e5\u5236\u5fa1\u3092\u884c\u3063\u3066\u304f\u308c\u307e\u3059\u304c\u3001 PHP\u3067\u9759\u7684\u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u8fd4\u3059\u3088\u3046\u306a\u51e6\u7406\u3092\u884c\u3063\u3066\u3044\u308b\u5834\u5408\u306b\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u5229\u7528\u3059\u308b\u306b\u306f Last-Modifie &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/clouds.tokyo\/blog\/php_cache\/\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;\u3010PHP\u3011Last-Modified\u30d8\u30c3\u30c0\u306b\u3088\u308b\u9759\u7684\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u5236\u5fa1&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"_jetpack_newsletter_access":""},"categories":[2],"tags":[300,301,96],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pezW3u-bD","jetpack-related-posts":[{"id":215,"url":"https:\/\/clouds.tokyo\/blog\/php_dl_header\/","url_meta":{"origin":721,"position":0},"title":"\u3010PHP\u3011\u30d5\u30a1\u30a4\u30eb\u3092\u51fa\u529b\u3059\u308b\u3068\u304d\u306eheader","author":"yamamoto","date":"2010\u5e741\u67088\u65e5","format":false,"excerpt":"\u30d5\u30a1\u30a4\u30eb\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3055\u305b\u308b\u5834\u5408\u306b\u306f header\u3092\u8a18\u8ff0\u3057\u3066\u304b\u3089\u30d5\u30a1\u30a4\u30eb\u5185\u5bb9\u3092\u51fa\u529b\u3057\u307e\u3059\u3002 head\u2026","rel":"","context":"\u5099\u5fd8\u9332","block_context":{"text":"\u5099\u5fd8\u9332","link":"https:\/\/clouds.tokyo\/blog\/category\/memo\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":714,"url":"https:\/\/clouds.tokyo\/blog\/ajax_cors\/","url_meta":{"origin":721,"position":1},"title":"\u3010Ajax\u3011\u901a\u4fe1\u30e1\u30bd\u30c3\u30c9\u304c\u52dd\u624b\u306bOPTIONS\u306b\u306a\u3063\u305f\u3089","author":"yamamoto","date":"2017\u5e745\u67082\u65e5","format":false,"excerpt":"\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u6761\u4ef6\u3067Ajax\u901a\u4fe1\u3092\u884c\u3046\u3068\u3001\u30d6\u30e9\u30a6\u30b6\u306f\u81ea\u52d5\u7684\u306b\u300c\u30d7\u30ea\u30d5\u30e9\u30a4\u30c8\u300d\u3068\u547c\u3070\u308c\u308b\u901a\u4fe1\u30c1\u30a7\u30c3\u30af\u3092\u884c\u2026","rel":"","context":"\u5099\u5fd8\u9332","block_context":{"text":"\u5099\u5fd8\u9332","link":"https:\/\/clouds.tokyo\/blog\/category\/memo\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":431,"url":"https:\/\/clouds.tokyo\/blog\/aws_ec2_s3\/","url_meta":{"origin":721,"position":2},"title":"\u3010AWS\u3011EC2\u304b\u3089S3\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u53d6\u5f97\u3057\u3066\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3055\u305b\u308b(PHP)","author":"yamamoto","date":"2016\u5e746\u670811\u65e5","format":false,"excerpt":"\u307e\u305a\u306fSDK\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u307e\u3059\u3002 Releases \u00b7 aws\/aws-sdk-php \u00b7 Git\u2026","rel":"","context":"\u5099\u5fd8\u9332","block_context":{"text":"\u5099\u5fd8\u9332","link":"https:\/\/clouds.tokyo\/blog\/category\/memo\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":506,"url":"https:\/\/clouds.tokyo\/blog\/php_fgc_stat\/","url_meta":{"origin":721,"position":3},"title":"\u3010PHP\u3011file_get_contents\u306e\u30a8\u30e9\u30fc\u51e6\u7406","author":"yamamoto","date":"2007\u5e7411\u670813\u65e5","format":false,"excerpt":"file_get_contents\u306f\u30d5\u30a1\u30a4\u30eb\u53d6\u5f97\u3060\u3051\u3067\u306a\u304f\u3001\u4ed6\u306e\u30b5\u30a4\u30c8\u306eAPI\u3092\u30b3\u30fc\u30eb\u3057\u305f\u308a\u3059\u308b\u3068\u304d\u2026","rel":"","context":"\u5099\u5fd8\u9332","block_context":{"text":"\u5099\u5fd8\u9332","link":"https:\/\/clouds.tokyo\/blog\/category\/memo\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":537,"url":"https:\/\/clouds.tokyo\/blog\/ajax_xdomain\/","url_meta":{"origin":721,"position":4},"title":"\u3010Ajax\u3011\u30af\u30ed\u30b9\u30c9\u30e1\u30a4\u30f3\u3067\u975e\u540c\u671f\u901a\u4fe1\u3092\u884c\u3046","author":"yamamoto","date":"2013\u5e747\u670827\u65e5","format":false,"excerpt":"\u30af\u30ed\u30b9\u30c9\u30e1\u30a4\u30f3\u3067\u975e\u540c\u671f\u901a\u4fe1\u3092\u884c\u3046\u65b9\u6cd5\u306e\u4e00\u3064\u306b\u3001 \u300cAccess-Control-Allow-Orig\u2026","rel":"","context":"\u5099\u5fd8\u9332","block_context":{"text":"\u5099\u5fd8\u9332","link":"https:\/\/clouds.tokyo\/blog\/category\/memo\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":205,"url":"https:\/\/clouds.tokyo\/blog\/php_log_origin\/","url_meta":{"origin":721,"position":5},"title":"\u3010PHP\u3011\u72ec\u81ea\u306e\u30ed\u30b0\u3092\u51fa\u529b\u3057\u3088\u3046","author":"yamamoto","date":"2015\u5e746\u67088\u65e5","format":false,"excerpt":"\u958b\u767a\u306b\u30c7\u30d0\u30c3\u30b0\u30ed\u30b0\u3001\u30a8\u30e9\u30fc\u30ed\u30b0\u306f\u6b20\u304b\u305b\u307e\u305b\u3093\u304c\u3001 \u6a19\u6e96\u30ed\u30b0\u3084\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306e\u30ed\u30b0\u3060\u3051\u3067\u306f\u60c5\u5831\u304c\u4e0d\u8db3\u3057\u2026","rel":"","context":"\u5099\u5fd8\u9332","block_context":{"text":"\u5099\u5fd8\u9332","link":"https:\/\/clouds.tokyo\/blog\/category\/memo\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/clouds.tokyo\/blog\/wp-json\/wp\/v2\/posts\/721"}],"collection":[{"href":"https:\/\/clouds.tokyo\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/clouds.tokyo\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/clouds.tokyo\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/clouds.tokyo\/blog\/wp-json\/wp\/v2\/comments?post=721"}],"version-history":[{"count":4,"href":"https:\/\/clouds.tokyo\/blog\/wp-json\/wp\/v2\/posts\/721\/revisions"}],"predecessor-version":[{"id":739,"href":"https:\/\/clouds.tokyo\/blog\/wp-json\/wp\/v2\/posts\/721\/revisions\/739"}],"wp:attachment":[{"href":"https:\/\/clouds.tokyo\/blog\/wp-json\/wp\/v2\/media?parent=721"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/clouds.tokyo\/blog\/wp-json\/wp\/v2\/categories?post=721"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/clouds.tokyo\/blog\/wp-json\/wp\/v2\/tags?post=721"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}