{"id":112,"date":"2010-04-26T20:09:19","date_gmt":"2010-04-26T11:09:19","guid":{"rendered":"http:\/\/blog.xcir.net\/?p=112"},"modified":"2012-06-01T02:09:29","modified_gmt":"2012-05-31T17:09:29","slug":"varnish%e3%81%aeinline-c%e3%81%a7%e6%a9%9f%e8%83%bd%e6%8b%a1%e5%bc%b5%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/blog.xcir.net\/?p=112","title":{"rendered":"Varnish\u306eInline-C\u3067\u6a5f\u80fd\u62e1\u5f35\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<p>\u3068\u3063\u3066\u3082\u4fbf\u5229\u306aVarnish\u3067\u3059\u304c\u3044\u308d\u3044\u308d\u3067\u304d\u306a\u3044\u3053\u3068\u304c\u3042\u3063\u3066\u305f\u307e\u306b\u306a\u3093\u3068\u304b\u51fa\u6765\u306a\u3044\u304b\u306a\u30fc\u3068\u304b\u60a9\u3080\u3053\u3068\u304c\u3042\u308a\u307e\u3059<br \/>\n\u7279\u306b\u65e5\u4ed8\u6f14\u7b97\u306b\u306f\u5f31\u3044\u6c17\u304c\u3057\u307e\u3059\u3002<br \/>\n\u4ee5\u524d\u7d39\u4ecb\u3057\u305fESI\u3067\u306eTTL\u3092\u5f37\u5f15\u306a\u6307\u5b9a\u306b\u3064\u3044\u3066\u3082\u65e5\u4ed8\u6f14\u7b97\u304c\u3067\u304d\u308c\u3070\u7c21\u5358\u306b\u30fb\u30fb\u30fb\u3068<br \/>\n\u3068\u3044\u3046\u3053\u3068\u3067\u30b5\u30f3\u30d7\u30eb\u7684\u306b<\/p>\n<ul>\n<li>\u30a2\u30af\u30bb\u30b9\u3055\u308c\u305f\u6642\u9593\u3092\u3082\u3068\u306bExpires\u3092\u4ed8\u4e0e<\/li>\n<\/ul>\n<p>\u3092\u3084\u3063\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059<\/p>\n<h3><!--more-->\u3069\u3046\u3084\u3063\u3066Inline-C\u306e\u8a18\u8ff0\u3092\u884c\u3046\u304b<\/h3>\n<p>\u516c\u5f0fWiki\u306b\u306fVCL\u306bInline-C\u3067\u304d\u308b\u3088\u30fc\u3050\u3089\u3044\u3057\u304b\u306a\u304f\u305d\u3053\u304b\u3089\u30ea\u30f3\u30af\u306b\u3042\u308bPDF\u306b\u7b54\u304c\u3042\u308a\u307e\u3059<\/p>\n<p><a title=\"Using Varnish or VCL for webmasters\" href=\"http:\/\/varnish-cache.org\/raw-attachment\/wiki\/VCLExamples\/varnish_vcl.pdf \" target=\"_blank\">Using Varnish or VCL for webmasters<\/a><\/p>\n<p>\u8981\u306f<\/p>\n<blockquote>\n<div id=\"_mcePaste\">varnishd -d -f [vcl\u30d5\u30a1\u30a4\u30eb] -C<\/div>\n<\/blockquote>\n<p>\u3067\u30c7\u30d0\u30c3\u30b0\u30b3\u30fc\u30c9\u3092\u51fa\u3057\u3066\u306a\u3093\u3068\u304b\u3057\u306a\u3055\u3044\uff01\u3068\u3044\u3046\u306e\u304c\u8aad\u307f\u53d6\u308c\u307e\u3059<br \/>\n\u5b9f\u969b\u306b\u3053\u306e\u30b3\u30de\u30f3\u30c9\u3092\u6253\u3064\u3068\u3053\u3093\u306a\u611f\u3058\u306eC\u8a00\u8a9e\u306e\u30b3\u30fc\u30c9\u304c(\u9577\u3005\u3068)\u51fa\u3066\u304d\u307e\u3059<\/p>\n<pre class=\"brush: c; \">\n\r\nstatic int\r\nVGC_function_vcl_pass (struct sess *sp)\r\n{\r\n\t\/* ... from (Default Line 74 Pos 5) *\/\r\n\t{\r\n\t\t{\r\n\t\t\tVRT_count(sp, 36);\r\n\t\t\tVRT_done(sp, VCL_RET_PASS);\r\n\t\t}\r\n\t}\r\n}\r\n\n<\/pre>\n<p>\u3053\u308c\u3092\u306a\u3093\u3068\u306a\u304f\u8aad\u307f\u3068\u3044\u3066\u306a\u3093\u3068\u306a\u304f\u6a5f\u80fd\u3092\u4f5c\u3063\u3066\u3044\u304d\u307e\u3059<\/p>\n<h3>Expires\u4ed8\u4e0e\u306e\u5834\u5408<\/h3>\n<p>\u4eca\u56de\u306e\u4ed5\u69d8\u306f\u4ee5\u4e0b\u306e\u611f\u3058\u3067<\/p>\n<ul>\n<li>\u30a2\u30af\u30bb\u30b9\u3057\u305f\u6642\u9593\u304b\u308930\u65e5\u5f8c\u306eExpires\u3092\u4ed8\u4e0e\u3059\u308b<\/li>\n<li>\u3059\u3067\u306bExpires\u304c\u4ed8\u4e0e\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u306f\u4ed8\u4e0e\u3057\u306a\u3044<\/li>\n<\/ul>\n<p>\u3063\u3066\u306a\u611f\u3058\u3067\u3059\u3002<br \/>\n\u3053\u306e\u5834\u5408vcl_deliver\u304c\u3044\u3044\u304b\u306a\u30fc\u3068\u601d\u3046\u306e\u3067\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u611f\u3058\u3067\u66f8\u3044\u3066\u307f\u307e\u3059<\/p>\n<h4>VCL\u30d5\u30a1\u30a4\u30eb\u306e\u5148\u982d\u90e8\u5206<\/h4>\n<p>\u65e5\u4ed8\u306e\u51e6\u7406\u3092\u884c\u3046\u306e\u3067time.h\u3092include\u3057\u3066\u3042\u3052\u307e\u3059<\/p>\n<pre class=\"brush: plain; \">\n\r\nC{\r\n\t#include &lt;time.h&gt;\r\n}C\r\n\n<\/pre>\n<h4>vcl_deliver\u90e8\u5206<\/h4>\n<pre class=\"brush: plain; \">\n\r\nsub vcl_deliver {\r\n\tif(!resp.http.Expires){\r\n\t\tC{\r\n\t\t\ttime_t timer;\r\n\t\t\tstruct tm *date;\r\n\t\t\tchar str[256];\r\n\t\t\ttime(&amp;timer);\r\n\t\t\ttimer+=3600*24*30;\r\n\t\t\tdate = localtime(&amp;timer);\r\n\t\t\tstrftime(str,255,&quot;%a, %d %h %Y %H:%M:%S %Z&quot;,date);\r\n\t\t\tVRT_SetHdr(sp, HDR_RESP, &quot;\\010Expires:&quot;, str, vrt_magic_string_end);\r\n\t\t}C\r\n\t}\r\n}\r\n\n<\/pre>\n<p>\u3053\u308c\u3060\u3051\u3067\u3059<br \/>\n\u4ed6\u306b\u3082\u3044\u308d\u3044\u308d\u95a2\u6570\u304c\u3042\u308b\u306e\u3067\u305d\u306e\u3046\u3061\u7d39\u4ecb\u3057\u3088\u3046\u304b\u306a\u30fc\u3068\u306f\u601d\u3044\u307e\u3059\u304c\u7279\u306b\u91cd\u8981\u306a\u70b9\u3092<\/p>\n<pre class=\"brush: plain; \">\n\r\nVRT_SetHdr(sp, HDR_RESP, &quot;\\010Expires:&quot;, str, vrt_magic_string_end);\r\n\n<\/pre>\n<p>\u30d8\u30c3\u30c0\u5909\u6570\u306b\u5024\u3092\u30bb\u30c3\u30c8\u3059\u308b\u95a2\u6570\u3067\u3059<\/p>\n<p><strong>\u7b2c1\u5f15\u6570<\/strong><br \/>\n\u56fa\u5b9a\u3067sp\u3092\u6e21\u3057\u307e\u3059<\/p>\n<p><strong>\u7b2c2\u5f15\u6570<\/strong><br \/>\n\u3069\u3053\u306e\u30d8\u30c3\u30c0\u306a\u306e\u304b\u3092\u7279\u5b9a\u3057\u307e\u3059<\/p>\n<ul>\n<li>HDR_REQ<br \/>\nreq.http.*\u306b\u76f8\u5f53<\/li>\n<li>HDR_RESP<br \/>\nresp.http.*\u306b\u76f8\u5f53<\/li>\n<li>HDR_OBJ<br \/>\nobj.http.*\u306b\u76f8\u5f53<\/li>\n<li>HDR_BEREQ<br \/>\nbereq.http.*\u306b\u76f8\u5f53<\/li>\n<\/ul>\n<p>\u4eca\u56de\u306f\u30ec\u30b9\u30dd\u30f3\u30b9\u3067\u3059<\/p>\n<p><strong>\u7b2c\u4e09\u5f15\u6570<\/strong><br \/>\nresp.http.Expires\u306eExpires\u90e8\u5206\u3092\u7279\u5b9a\u3059\u308b\u306e\u3067\u3059\u304c\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059<br \/>\n\u6700\u521d\u306e1\u30d0\u30a4\u30c8\u76ee\u306b\u5f8c\u7d9a\u6587\u5b57\u5217(:\u307e\u3067\u542b\u3080)\u306e\u6587\u5b57\u5217\u9577\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p><strong>\u7b2c\u56db\u5f15\u6570\u4ee5\u964d<\/strong><br \/>\n\u4efb\u610f\u306e\u6587\u5b57\u5217(char*)\u3067\u8907\u6570\u500b\u6307\u5b9a\u304c\u53ef\u80fd\u3067\u3059<\/p>\n<p><strong>\u672b\u7aef\u5f15\u6570<\/strong><br \/>\nvrt_magic_string_end\u3092\u6307\u5b9a\u3057\u3066\u304a\u3057\u307e\u3044\u3067\u3059<\/p>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u30ec\u30b9\u30dd\u30f3\u30b9\u30d8\u30c3\u30c0\u306b<\/p>\n<pre class=\"brush: plain; \">\n\r\nExpires:\u00a0Wed, 26 May 2010 10:38:21 UTC\r\n\n<\/pre>\n<p>\u307f\u305f\u3044\u306a\u611f\u3058\u3067\u4ed8\u4e0e\u3055\u308c\u307e\u3059<\/p>\n<p>2012\/06\/01<br \/>\n\u7b2c\u4e09\u5f15\u6570\u306b\u3057\u3087\u3046\u3082\u306a\u3044\u30df\u30b9\u304c\u3042\u3063\u305f\u306e\u3067\u4fee\u6b63\u3057\u307e\u3057\u305f\u30fb\u30fb\u30fb<\/p>\n<div class='wp_social_bookmarking_light'>        <div class=\"wsbl_hatena\"><a href='\/\/b.hatena.ne.jp\/add?mode=confirm&url=https%3A%2F%2Fblog.xcir.net%2F%3Fp%3D112&title=Varnish%E3%81%AEInline-C%E3%81%A7%E6%A9%9F%E8%83%BD%E6%8B%A1%E5%BC%B5%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95' title='\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='https:\/\/blog.xcir.net\/wp-content\/plugins\/wp-social-bookmarking-light\/public\/images\/hatena.gif' alt='\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0' title='\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0' width='16' height='12' class='wp_social_bookmarking_light_img' \/><\/a><\/div>        <div class=\"wsbl_hatena_users\"><a href='\/\/b.hatena.ne.jp\/entry\/https:\/\/blog.xcir.net\/?p=112' title='\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af - Varnish\u306eInline-C\u3067\u6a5f\u80fd\u62e1\u5f35\u3059\u308b\u65b9\u6cd5' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='\/\/b.hatena.ne.jp\/entry\/image\/https:\/\/blog.xcir.net\/?p=112' alt='\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af - Varnish\u306eInline-C\u3067\u6a5f\u80fd\u62e1\u5f35\u3059\u308b\u65b9\u6cd5' title='\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af - Varnish\u306eInline-C\u3067\u6a5f\u80fd\u62e1\u5f35\u3059\u308b\u65b9\u6cd5'   class='wp_social_bookmarking_light_img' \/><\/a><\/div>        <div class=\"wsbl_facebook\"><a href='http:\/\/www.facebook.com\/share.php?u=https%3A%2F%2Fblog.xcir.net%2F%3Fp%3D112&t=Varnish%E3%81%AEInline-C%E3%81%A7%E6%A9%9F%E8%83%BD%E6%8B%A1%E5%BC%B5%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95' title='Facebook \u306b\u30b7\u30a7\u30a2' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='https:\/\/blog.xcir.net\/wp-content\/plugins\/wp-social-bookmarking-light\/public\/images\/facebook.png' alt='Facebook \u306b\u30b7\u30a7\u30a2' title='Facebook \u306b\u30b7\u30a7\u30a2' width='16' height='16' class='wp_social_bookmarking_light_img' \/><\/a><\/div>        <div class=\"wsbl_linkedin\"><a href='\/\/www.linkedin.com\/shareArticle?mini=true&url=https%3A%2F%2Fblog.xcir.net%2F%3Fp%3D112&title=Varnish%E3%81%AEInline-C%E3%81%A7%E6%A9%9F%E8%83%BD%E6%8B%A1%E5%BC%B5%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95' title='LinkedIn \u306b\u30b7\u30a7\u30a2' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='https:\/\/blog.xcir.net\/wp-content\/plugins\/wp-social-bookmarking-light\/public\/images\/linkedin.png' alt='LinkedIn \u306b\u30b7\u30a7\u30a2' title='LinkedIn \u306b\u30b7\u30a7\u30a2' width='16' height='16' class='wp_social_bookmarking_light_img' \/><\/a><\/div>        <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/blog.xcir.net\/?p=112\" data-text=\"Varnish\u306eInline-C\u3067\u6a5f\u80fd\u62e1\u5f35\u3059\u308b\u65b9\u6cd5\" data-lang=\"ja\">Tweet<\/a><\/div><\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>\u3068\u3063\u3066\u3082\u4fbf\u5229\u306aVarnish\u3067\u3059\u304c\u3044\u308d\u3044\u308d\u3067\u304d\u306a\u3044\u3053\u3068\u304c\u3042\u3063\u3066\u305f\u307e\u306b\u306a\u3093\u3068\u304b\u51fa\u6765\u306a\u3044\u304b\u306a\u30fc\u3068\u304b\u60a9\u3080\u3053\u3068\u304c\u3042\u308a\u307e\u3059 \u7279\u306b\u65e5\u4ed8\u6f14\u7b97\u306b\u306f\u5f31\u3044\u6c17\u304c\u3057\u307e\u3059\u3002 \u4ee5\u524d\u7d39\u4ecb\u3057\u305fESI\u3067\u306eTTL\u3092\u5f37\u5f15\u306a\u6307\u5b9a\u306b\u3064\u3044\u3066\u3082\u65e5\u4ed8\u6f14\u7b97\u304c\u3067\u304d\u308c\u3070\u7c21\u5358 <a href='https:\/\/blog.xcir.net\/?p=112' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[5,13,25],"class_list":["post-112","post","type-post","status-publish","format-standard","hentry","category-3","tag-varnish","tag-varnish2-0-6","tag-c","category-3-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"_links":{"self":[{"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/posts\/112","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=112"}],"version-history":[{"count":14,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/posts\/112\/revisions"}],"predecessor-version":[{"id":1136,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/posts\/112\/revisions\/1136"}],"wp:attachment":[{"href":"https:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}