ããæ°å¹´ã®å¾åã¯ãWebãµã¤ãã®ãã¶ã¤ã³ãã¢ããªã«ä¼¼ã¦ãã¦ãã¾ãã
é«åº¦ãªå¿çæ§ã¨åæ¹åæ§ã¯ãå¹ åºãã³ã³ãã³ãã¨åããããéè¦ã§ãã
ç¾ä»£ã§ã¯ã主ã«Webããã¸ã§ã¯ããã¬ã³ããªã³ã°ããããã«æ示ããã¦ãã3ã¤ã®æ¦ç¥ã§ããCSR
ã»SSR
ã»SSG
ããããã¾ãã
å½è¨äºã§ã¯Webåå¿è ã®ããã«æãåºæ¬çãªCSRã¨SSRããã³SSGã«ã¤ãã¦è§£èª¬ãã¦ããã¾ãã
SSRããã³SSGã¯ãã¡ãã®Reactを使用した静的Webサイト制作のためのレンダリング戦略 - deve.K's Programming Primer - プログラミング初心者のための入門ブログã§ã触ãã¦ããã¾ãã®ã§åç §ä¸ããã
ã¾ãã4ã¤ç®ã®ISRãIntelligent Sampling and Renderingãï¼ã¤ã³ããªã¸ã§ã³ãã»ãµã³ããªã³ã°ã»ã¢ã³ãã»ã¬ã³ããªã³ã°ï¼ã¨ããã¬ã³ããªã³ã°æ¦ç¥ããããã¾ããæ¬æ¥ã§ã¯è§£èª¬è´ãã¾ããã®ã§ãäºæ¿ä¸ããã
ã¯ã©ã¤ã¢ã³ããµã¤ãã¨ã¯ï¼
ã¯ã©ã¤ã¢ã³ããµã¼ãã¼ã¢ãã«ã§ã¯ãã¦ã¼ã¶ã¼ã¯ã³ã³ãã¥ã¼ã¿ã¼ããµã¼ãã¼ã«æ¥ç¶ãã¦ããã¤ãããã¯ãªWebãµã¤ããé²è¦§ãã¾ãã
ãã®ã¢ãã«ã§ã¯ããµã¼ãã¼ãæ å ±ãæä¾ããã¦ã¼ã¶ã¼ã®ããã¤ã¹ï¼ã¯ã©ã¤ã¢ã³ãï¼ããããåä¿¡ãã表示ããä»çµã¿ã§ãã
ã¯ã©ã¤ã¢ã³ããµã¤ãã¨ã¯ãã¦ã¼ã¶ã¼ã®ããã¤ã¹ä¸ã§åä½ããã½ããã¦ã§ã¢ãããã°ã©ã ã®ãã¨ãæãã¾ãã
ä¸è¬çã«ãWebéçºã®ããã³ãã¨ã³ãã¨ãã¦ãç¥ããã主ã«HTMLãCSSãããã¦JavaScriptãå©ç¨ããã¾ãã
ãããã®æè¡ãçµã¿åããããã¨ã§ãã¦ã¼ã¶ã¼ã«è¦æ ãã®è¯ãã¤ã³ã¿ã©ã¯ãã£ããªWebãã¼ã¸ãæä¾ã§ãã¾ãã
ã¦ã¼ã¶ã¼ãç´æ¥æä½ããã³ã³ãã³ãã ãã§ãªãããµã¼ãã¼ãµã¤ãã§åçã«çæãããã³ã³ãã³ããå«ã¾ãã¾ãã
ããããåçãªã³ã³ãã³ããæ±ãããã«ãéçãªJSONãã¡ã¤ã«ã使ã£ã¦ãã¡ã¤ã«ã«åçã«ã¢ã¯ã»ã¹ãããã¨ãä¸è¬çã§ãã
ã¾ããAJAXã¨å¼ã°ããææ³ãç¨ãããã¨ã§ãã¯ã©ã¤ã¢ã³ããµã¤ãã®Webãµã¤ãã«ããã¦ã³ã³ãã³ããåçã«èªã¿è¾¼ãã§å¤æ´ãããã¨ãã§ãã¾ãã
éè¦ãªç¹ã¨ãã¦ãã¯ã©ã¤ã¢ã³ããµã¤ãã®ããã°ã©ã ã¯å¿ ããããã©ã¦ã¶ã«ä¾åããããã§ã¯ããã¾ããã
é常ãã¯ã©ã¤ã¢ã³ããµã¤ãã®ããã°ã©ã ã¯ãã©ã¦ã¶ä¸ã§å®è¡ããã¾ãããNode.jsãªã©ã®ç°å¢ã使ç¨ãããã¨ã§ããµã¼ãã¼ã§ã¯ãªãã¯ã©ã¤ã¢ã³ããµã¤ãã§JavaScriptãå®è¡ãããã¨ãã§ãã¾ãã
ããã«ãã¯ã©ã¤ã¢ã³ããµã¤ãã®ããã°ã©ã ã¯ãã¦ã¼ã¶ã¼ã®ããã¤ã¹ä¸ã ãã§ãªããä»ã®ç°å¢ããã©ãããã©ã¼ã ã§ãå®è¡å¯è½ã§ããããã«ãããã¯ã©ã¤ã¢ã³ããµã¤ãã®éçºã«ããã¦ã¯ããã©ã¦ã¶ã«éå®ãããªãæè»æ§ãçã¾ãã¾ãã
Webéçºã«ããã¦ã¯ã常ã«å¦ç¿ãç¶ç¶ãããã¨ãéè¦ã§ãã
æè¡ã¯çµ¶ããé²åãã¦ãããæ°ããæè¡ããã¹ããã©ã¯ãã£ã¹ãç»å ´ãã¦ãã¾ãã
ã³ãã¥ããã£ããªã³ã©ã¤ã³ãªã½ã¼ã¹ãæ´»ç¨ãã¦æ å ±åéããèªèº«ã®ã¹ãã«ãåä¸ããããã¨ã§ãããè¯ãWebãµã¤ãã®éçºã«è²¢ç®ã§ããã§ãããã
ãµã¼ãã¼ãµã¤ãã¨ã¯ï¼
ããµã¼ãã¼ãµã¤ãéçºãã¨ã¯ãWebãµã¼ãã¼ä¸ã§åä½ããããã°ã©ã ãå«ãã極ãã¦éè¦ãªéçºææ³ã§ãã
Webãã©ã¦ã¶ãã¯ã©ã¤ã¢ã³ããµã¤ãã¯ãWebãµã¼ãã¼ã¨ã®ç¸äºä½ç¨ãéãã¦æ å ±ãåå¾ããããããã®åéã®ããã°ã©ãã³ã°ã¯é常ã«éè¦ã§ãã
ãµã¼ãã¼ãµã¤ãã¯ãã¦ã¼ã¶ã¼ã®ãªã¯ã¨ã¹ãã«å¿ãã¦ãã¾ãã¾ãªå¦çãè¡ããæ å ±ã®äº¤æãå¯è½ã«ãã¾ããä¾ãã°ãã¦ã¼ã¶ã¼ããã®å ¥åãåãåã£ã¦ãã¼ã¿ãã¼ã¹ã¨ããåãããçµæãå å·¥ãã¦ã¯ã©ã¤ã¢ã³ããµã¤ãã«è¿ãã¨ãã£ãå½¹å²ãæããã¾ãã
ããã¯ããã¯ã¨ã³ãã¨ãå¼ã°ãããã¼ã¿ã¨ã½ã¼ã¹ã³ã¼ããæ ¼ç´ãããå ´æã§ãã
ã¦ã¼ã¶ã¼ã¯ãµã¼ãã¼å´ã®å¦çãç´æ¥ç®ã«ãããã¨ã¯ããã¾ããã
主è¦ãªãµã¼ãã¼ãµã¤ãè¨èªã«ã¯ãJavaãPHPã.NETãPythonãããã¦Ruby on Railsï¼ã¾ãã¯åã«Railsï¼ãªã©ãããã¾ãã
åè¨èªã«ã¯ç¬èªã®ç¹æ§ããããç¨éã«å¿ãã¦é©åãªè¨èªãé¸æãããã¨ãéè¦ã§ãã
ãµã¼ãã¼ãµã¤ãã®ã³ã¼ãã¯é常ãµã¼ãã¼ä¸ã«åå¨ããã¯ã©ã¤ã¢ã³ããµã¤ãã®ã³ã¼ããã¨ã³ãã¦ã¼ã¶ã¼ã«æä¾ããå½¹å²ãæããã¾ãããã®ããããµã¼ãã¼ãµã¤ãã®ããã©ã¼ãã³ã¹ãã»ãã¥ãªãã£ã®æé©åãéè¦ã«ãªãã¾ãã
ã¦ã§ããµã¤ããä¸è¬ã«ã¢ã¯ã»ã¹å¯è½ã§ããå ´åãç´ç²ãªã¯ã©ã¤ã¢ã³ããµã¤ãã®ã¿ã§ãã£ã¦ããã©ããã®ãµã¼ãã¼ã«é ç½®ãããå¿ è¦ãããã¾ãã
ã¾ããå¤ãã®Webã¢ããªã±ã¼ã·ã§ã³ã¯ã¯ã©ã¤ã¢ã³ããµã¤ãã¨ãµã¼ãã¼ãµã¤ãã®çµã¿åããã§æ§ç¯ããã¾ãã
ãã ãããµã¼ãã¼ãµã¤ãã®ã³ã¼ãã¯æè¡çã«ã¯ã¯ã©ã¤ã¢ã³ããµã¤ãã®ã³ã¼ãã¨ç´æ¥çã«å¯¾è©±ããå¿ è¦ã¯ããã¾ãããã¯ã©ã¤ã¢ã³ãããã®ãªã¯ã¨ã¹ããåãåããé©åãªã¬ã¹ãã³ã¹ãçæãããã¨ã主ãªå½¹å²ã§ãã
ãµã¼ãã¼ãµã¤ãã®ã³ã¼ãã¯ããã¼ã¿ã®å¦çãåæãªã©ãè£å´ã§å¤ãã®è¤éãªã¿ã¹ã¯ãå®è¡ãããã¨ãããã¾ãã
ãããã®ã³ã¼ãã¯ããã¼ã¿ãã¼ã¹ããã®ä»ã®ãã¼ã¿ã¹ãã¢ã¨é£æºãã¦ãã¤ã³ã¿ã©ã¯ãã£ããªWebãµã¤ããæä¾ããããã«ä½¿ããã¾ãã
ã¾ãããµã¼ãã¼ãµã¤ãã®ã³ã¼ãã¯ã»ãã¥ãªãã£ä¸ã®éè¦ãªé¨åã§ãããã¾ããã¦ã¼ã¶ã¼ããã®ãã¼ã¿ã®æ¤è¨¼ãé©åãªã¢ã¯ã»ã¹å¶å¾¡ãè¡ããã¨ã§ãæªæããæ»æããã·ã¹ãã ãä¿è·ãã¾ãã
çµå±ã®ã¨ããããµã¼ãã¼ãµã¤ãã®ã³ã¼ãããªããã°ãã¤ã³ã¿ã¼ããããç¾å¨ã®ãªã³ã©ã¤ã³ä¸ã§è¡ããã¦ããå¤ãã®ãã¨ã¯ä¸å¯è½ã¨ãªãã¾ãã
ãã®éè¦æ§ãããã©ã®ãããªéçºè ã§ãã£ã¦ãããã®åéã«ã¤ãã¦ç解ãã¦ãããã¨ã¯æ¥µãã¦éè¦ã§ãã
æè¡ã®é²åã¨ã¨ãã«ãæ°ãããµã¼ãã¼ãµã¤ãã®ãã¬ã¼ã ã¯ã¼ã¯ããã¼ã«ãç»å ´ãã¦ãã¾ãã®ã§ã常ã«å¦ç¿ã¨ã¹ãã«ã®åä¸ãå¿ããããã¨ã大åã§ãã
ã¯ã©ã¤ã¢ã³ããµã¤ãã¬ã³ããªã³ã°
Client-Side-Rendering ï¼CSRï¼ã¯ããã©ã¦ã¶ãã¢ã¯ã»ã¹è¦æ±ãå¦çããJavaScriptãã¡ã¤ã«ã®ã¿ã使ç¨ã㦠HTMLã³ã³ãã³ããçæããã¬ã³ããªã³ã°æ¹æ³ã§ãã
CSRã¯Webãµã¤ããã¬ã³ããªã³ã°ããããã®ããªãæ°ããã¢ããã¼ãã§ãããJavaScriptã©ã¤ãã©ãªã«çµã¿è¾¼ã¾ããã¾ã§ãã¾ãæ®åãã¾ããã§ããã
ç¾ä»£ã§ã®éçºã§ã¯ä¸»ã«JSã©ã¤ãã©ãªã¨ãã¬ã¼ã ã¯ã¼ã¯ã«é¢ãããã®ã§ãããããéçºè ã¯CSRã«ã¢ããã¼ããã¦ãã¾ãã
ç¾ä»£ã®JSã®äººæ°ã¯ããã¹ã¦ã®é¢å¿ãCSRã«ç§»ãã¦ããã¾ãã
ãã©ã¦ã¶ã¯Webãµã¤ãã®åæå®è¡æã«ãã¼ã¿ãã¯ã©ã¤ã¢ã³ãã®ãã©ã¦ã¶ã«ãã¼ããã¾ãã
ãããçµããã¨ãWebã¯åçã«èªã¿è¾¼ã¾ãã¾ãã
Webãµã¤ãã®ããã²ã¼ã·ã§ã³ãå¶å¾¡ããã¯ã©ã¤ã¢ã³ãã®ãã©ã¦ã¶ã§DOMãå¦çãã¾ãã
ãã®ããã»ã¹ã«ã¯ãWebãµã¼ãã¼ã§ã¯ãªãã¯ã©ã¤ã¢ã³ããµã¤ã (ãã©ã¦ã¶) ã§ã®ãã¼ã¿ã®ãã§ããã¨å¦çãå«ã¾ããããããã¯ã©ã¤ã¢ã³ããµã¤ãã¬ã³ããªã³ã°ãã¨ããååãä»ãããã¦ãã¾ãã
ã¯ã©ã¤ã¢ã³ãå´ã¬ã³ããªã³ã°ã®åªãã使ç¨ä¾ã¯ãã·ã³ã°ã«ãã¼ã¸ã¢ããªã±ã¼ã·ã§ã³ (SPA) ã§ãã
SPAã§ã¯ãåãã¼ã¸ãã¯ã©ã¤ã¢ã³ããã©ã¦ã¶ã§ã¬ã³ããªã³ã°ããã¾ãã
ãµã¼ãã¼ã¯1ã¤ã®HTMLããã¥ã¡ã³ãã®ã¿ãæä¾ãã¾ãã
ã¯ã©ã¤ã¢ã³ããµã¤ãã§ã®éçºã¯ãã¦ã¼ã¶ã¼ãè¦ããã¨ãã§ããã¢ããªã±ã¼ã·ã§ã³ã®ããã³ãé¨åã«ç¦ç¹ãå½ã¦ã¦ãã¾ãã®ã§ãã¯ã©ã¤ã¢ã³ããµã¤ãã®éçºè ã¯ã次ã®ãããªãã¾ãã¾ãªã¿ã¹ã¯ãå®äºãã¾ãã
ã» Webãµã¤ãã®ã¬ã¤ã¢ã¦ãä½æ
ã» ã¦ã¼ã¶ã¼ã¤ã³ã¿ã¼ãã§ã¤ã¹è¨è¨
ã» ãã©ã¼ã æ¤è¨¼ã®è¿½å
ã» è²ããã©ã³ããªã©ã®è¦è¦çãªãã¶ã¤ã³è¦ç´ ã追å ãã
ã» Webãµã¤ãã¯ä¸»ã«æ å ±æä¾ã«æé©ãªã®ã§ãã¦ã¼ã¶ã¼ããµã¤ãã§ééããåé¡ã解決ãã
ã» Webãµã¤ãã®ããã©ã¼ãã³ã¹ã®ã¬ãã¥ã¼
ã¯ã©ã¤ã¢ã³ããµã¤ãã®ä¸»ãªå©ç¹ã¯ã軽éã§å®è£ ãæ¯è¼çç°¡åã§ãããã¨ã§ãã
ã¤ã¾ãæ§æãè¤éãããªãäºã§ãããã³ã¼ãã®ç·¨éã¨å®è¡ã¯é«éã§ãã
ããã¦ãé常ã«ç°¡åã«ç¿å¾ãã¦ä½¿ç¨ã§ãã¾ãã
ããããæå°éã®ããã°ã©ãã³ã°ç¥èã¾ãã¯çµé¨ãå¿ è¦ã¨ãªãã¾ãã
ã¯ã©ã¤ã¢ã³ããµã¤ãã®ã©ã¤ãã©ãªãéçºãã¼ã«ã®99%ã¯ç¡æã§ä½¿ç¨ã§ããã³ã¹ããããããªã½ã¼ã¹ã¯ãããããã¨ãªã£ã¦ããã¾ãã
ã¯ã©ã¤ã¢ã³ããµã¤ãã«ã¯ãå¿çæéã®ç縮ãããã¤ã³ã¿ã©ã¯ãã£ããªã¢ããªã±ã¼ã·ã§ã³ãWebãµã¼ãã¼ã®ãªã¼ãã¼ãããã®åæ¸ãªã©ãå¤ãã®å©ç¹ãããã¾ãã
ã¯ã©ã¤ã¢ã³ããµã¤ãã®ãã¡ãªããã§ã¯ä¸»ã«å®å ¨ã¨ä¿¡é ¼æ§ã§ãã
ã¹ã¯ãªããè¨èªã使ç¨ããããã«ã¯ãããå¤ãã®æéã¨å´åãå¿ è¦ã§ãããã¯ã©ã¤ã¢ã³ãã®ãã©ã¦ã¶ããã®ã¹ã¯ãªããè¨èªããµãã¼ãããå¿ è¦ããããã¨ã§ãã
ã¤ã¾ããæ®å¿µãªãããã¾ãã¾ãªãã©ã¦ã¶ã§ãµãã¼ãããã¦ããè¨èªã§ãã£ã¦ãããã¹ã¦ã®ãã©ã¦ã¶ãã¼ã¸ã§ã³ã¨OSã§ã¾ã£ããåãããã«å®è£ ããã¦ããã¨ã¯éãã¾ããã
éçºè ã¯ã使ç¨ããåã«ãã¾ãã¾ãªãã©ãããã©ã¼ã ã§ã®ã¯ã©ã¤ã¢ã³ããµã¤ãã®ã¹ã¯ãªããåä½ã確èªããå¿ è¦ããããã¾ãã
ã¯ã©ã¤ã¢ã³ããµã¤ãã¯ãæ¬è³ªçã«å®å ¨ã§ã¯ããã¾ããã
ã¯ã©ã¤ã¢ã³ãã«æä¾ãããã³ã¼ãã«ã¢ã¯ã»ã¹ããããããããµã¼ãã¼å´ã®ã¹ã¯ãªãããããå®å ¨æ§ãä½ããªãã¾ãã
ã¤ã¾ããWebè¦æ±ã«åãè¾¼ã¾ããæªæã®ããHTMLã¿ã°ã«ããããµã¼ãã¼ãä¸æ£ãªå½¢å¼ã®ãã¼ã¸ãçæããå¯è½æ§ãããã¾ãã
ããããµã¼ãã¼ãµã¤ãã§å®è¡ããã¨å±éºã§ãã
ã¯ã©ã¤ã¢ã³ãã«éãè¿ãããä¸æ£ãªãã¼ã¸ãã¯ã©ã¤ã¢ã³ããµã¤ãã§å®è¡ãããã¨ãããã«åé¡ãçºçããå¯è½æ§ãããã¾ãã
ä¸é¨ã®ã¦ã¼ã¶ã¼ã¯ãã¹ã¯ãªããã®å®è¡ãç¡å¹ã«ãããã®ã¹ã¯ãªããææ³ã®æç¨æ§ãå¶éãã¦ãã¾ãã
ã§ãã®ã§ãã¦ã¼ã¶ã¼ã¯ãªãã¹ãã³ã³ãã¥ã¼ã¿ã¼ã¨ãã¼ã¿ãæ°ããèå¼±æ§ã«ãããããªãããã«ãWebãã©ã¦ã¶ã常ã«ææ°ã®ç¶æ ã«ä¿ã¤ãã¨ããå§ãè´ãã¾ãã
ããã¦ãè² è·ã®é«ãJavaScriptã«åºã¥ãWebã¢ããªã±ã¼ã·ã§ã³ã¯ããããã°ã¨ä¿å®ãè¤éã«ãªãå¯è½æ§ãããã¾ãã
é常ãã¯ã©ã¤ã¢ã³ããµã¤ãã®ã¹ã¯ãªããè¨èªã¯ããµã¼ãã¼å´ã®ã¹ã¯ãªããè¨èªãããæ©è½ãå¶éããã¦ããã¾ãã
ãã¼ã¿ãã¼ã¹ã«ã¢ã¯ã»ã¹ããå¿ è¦ãããå ´åãã¾ãã¯æ©å¯ãã¼ã¿ãã¤ã³ã¿ã¼ãããçµç±ã§éä¿¡ããå¿ è¦ãããå ´åã§ã¯ãã¯ã©ã¤ã¢ã³ããµã¤ãã®ããã°ã©ãã³ã°è¨èªã¯ä½¿ç¨ã§ãã¾ããã
ããã¦ãã¯ã©ã¤ã¢ã³ããµã¤ãã®ã¬ã³ããªã³ã°ã§ã¯ãååã®ãã¼ã¸ã®èªã¿è¾¼ã¿ã¯èªç¶ã«å°ãé ããªãã¾ãã
ãã®åå ã¯ãè¤æ°ã®ãã¼ã¸ã«å¿ è¦ãªãã¬ã¼ã ã¯ã¼ã¯ãã¢ããªã³ã¼ããããã³ã¢ã»ããã®èªã¿è¾¼ã¿ãåå ã§ãååã®ãã¼ã¸ã®èªã¿è¾¼ã¿ãéããªãã¾ãã
ååã®èªã¿è¾¼ã¿ã¯ãã¦ã¼ã¶ã¼ã«æ°ç§é空ç½ã®ç»é¢ã表示ãããã¨ãªããé«éã§ããå¿ è¦ãããã¾ãã
èªã¿è¾¼ã¿ã«æéããããã¨ãã¦ã¼ã¶ã¼ã®å°è±¡ãæªããªãã¾ãã
ãã ãã1度èªã¿è¾¼ãã§ãã¾ãã°ãã®å¾ã®ãã¹ã¦ã®ãã¼ã¸ã®èªã¿è¾¼ã¿ã¯é常ã«é«éã§ãã
ãã®ã¢ããã¼ãã§ã¯ããµã¼ãã¼ã¨ã®éä¿¡ã¯å®è¡æãã¼ã¿ãåå¾ããããã ãã«è¡ããã¾ãã
ããã«ããµã¼ãã¼ãå¼ã³åºããã³ã«UIå ¨ä½ããªãã¼ãããå¿ è¦ã¯ããã¾ããã
ã¯ã©ã¤ã¢ã³ããµã¤ããã¬ã¼ã ã¯ã¼ã¯ã¯ãç¹å®ã®DOMè¦ç´ ã®ã¿ãåã¬ã³ããªã³ã°ãããã¨ã§ãå¤æ´ããããã¼ã¿ã§UIãæ´æ°ãã¾ãã
Angular
ã¨React.js
ã¯ãã¯ã©ã¤ã¢ã³ããµã¤ãã®ã¬ã³ããªã³ã°ã§ä½¿ç¨ãããã©ã¤ãã©ãªã®æè¯ã®ä¾ã¨ãªã£ã¦ãã¾ãã
ããã¯ãCSRã¯ã»ã¨ãã©ã®å ´åã§å¤é¨ã©ã¤ãã©ãªãå¿ è¦ã¨ããäºã«ããªãçæã®ï¼ã¤ã§ãã
ã¾ãããã¹ã¦ã®æ¤ç´¢ã¨ã³ã¸ã³ã¯ã¯ãã¼ã«ä¸ã«JavaScriptãå®è¡ãã¦ããããããã¼ã¸ã«ç©ºã®ã³ã³ãã³ãã表示ãããå ´åãããã¾ãã
ããã«ãã£ã¦ãã¢ããªã®æ¤ç´¢ã¨ã³ã¸ã³æé©å(SEO)ãæå³ããæãªãããå¯è½æ§ããããã¾ãã
ãããå
æããã«ã¯ãã¢ããªããµã¼ãã¼ãµã¤ãã§ã¬ã³ããªã³ã°ããããPrerender
ãªã©ã®ãµã¼ãã¹ã使ç¨ãã¦JavaScriptããã©ã¦ã¶ã§ã¬ã³ããªã³ã°ããéç HTMLãä¿åãã¦ããããã¯ãã¼ã©ã¼ã«è¿ããã¨ãã§ãã¾ãã
æãéè¦ãªäºã¯ãæ¢ã«é ç½®ããã¦ããHTMLãã¡ã¤ã«ãçæããï¼SSGï¼ããæåã«è¦æ±ãå¦çãã¦ããããã®å ´ã§HTMLãçæï¼SSRï¼ããå¿ è¦ããããã決å®ãããã¨ã§ãã
å®éã«ã¯ãã»ã¨ãã©ã®ã¦ã¼ã¹ã±ã¼ã¹ã§SSGã¾ãã¯SSRã使ç¨ã§ãã¾ãã
ãµã¼ãã¼ãµã¤ãã¬ã³ããªã³ã°
Server-Side-Rendering ï¼SSRï¼ã¯World Wide Webã®åæã®é ã¯ãC
ãPerl
ããªã©ã®ã³ãã³ãã©ã¤ã³ã¹ã¯ãªããã§ããã°ã©ã ãä½æããéçºè
ã«ãã£ã¦ã»ã¼ç¬å çã«å®è¡ããã¦ãã¾ããã
ç¾ä»£ã§ã®SSRã®å
¸åçãªããã°ã©ãã³ã°è¨èªã¯Java
ãRuby
ãASP.NET
ãPerl
ãPHP
ãPython
ãNode.js/JavaScript
ãªã©ãã¾ãã¾ã§ãã
ããã¯ãã¯ã©ã¤ã¢ã³ããµã¤ãã®ã¬ã³ããªã³ã°ã¨ã¯æ£å対ã§ãã
SSRãã¯ããã¸ã¼ã§ã¯ãã¬ã³ããªã³ã°ã¯ãµã¼ãã¼ã«ãã£ã¦è¡ãããã¦ã¼ã¶ã¼ããµã¼ãã¼ã«ãªã¯ã¨ã¹ããéä¿¡ãã¾ãã
SSRã®å¤§ããªå©ç¹ã¯ãåWebãã¼ã¸ã®ãªã¯ã¨ã¹ãã¯ãµã¼ãã¼ã«ãã£ã¦å¦çããããã¨ã§ãã
ãããã£ã¦ããªã¯ã¨ã¹ãã¯ã¦ã¼ã¶ã¼ã®è¦³ç¹ããã»ã¼å³åº§ã«å¦çããããããWebãã¼ã¸ã¯é常ã«è¿ éã«è¡¨ç¤ºããã¾ãã
ãã©ã¦ã¶ã¯ããã¹ã¦ã®æ°ãããã¼ã¸ã¨åè¦æ±ã«å¯¾ãã¦ã常ã«ãµã¼ãã¼ã«è¦æ±ãè¡ã£ã¦ãã¾ãã
Webãã¼ã¸ã®HTMLã¯ãµã¼ãã¼ãµã¤ãã§çæãããããããã©ã¦ã¶ã®Javascriptãç¡å¹ã«ãªã£ã¦ãã¦ãWebãã¼ã¸ã¯è¡¨ç¤ºããã¾ãã
ãã©ã¦ã¶ã¯JSã³ã¼ããå®è¡ããããã使ç¨ãã¦Vueããã³Reactãã³ã¼ãã£ã³ã°ãã¾ãã
ããã¦ãã¼ã¸ãããã¤ã³ã¿ã©ã¯ãã£ãã¨ãªãã¾ãã
ããã«ãããã¬ã³ããªã³ã°ããã³ã¼ããå°ãªããããWebãµã¤ãã®ååã®ãã¼ã¸ã®èªã¿è¾¼ã¿ãé«éã¨ãªãã¾ãã
ååèªã¿è¾¼ã¿ãé«éã«ãªãå©ç¹ã§ãæ¤ç´¢ã¨ã³ã¸ã³ã¯ããè¯ãSEOã®ããã«ãµã¤ããã¯ãã¼ã«ã§ãã¾ãã
ã§ããããµã¼ãã¼ã¯ãªã¯ã¨ã¹ããã¨ã«å¿çãçæããå¿ è¦ããããããããã©ã¼ãã³ã¹ã¯ä¾ç¶ã¨ãã¦è¯å¥½ã§ãããæé«ã¨ã¯è¨ãã¾ããã
SSRã®æ¬ ç¹ã¯ãªã½ã¼ã¹ã大éã«æ¶è²»ããã¦ã¼ã¶ã¼ã¸ã®ã³ã³ãã³ãé ä¿¡ãé ãããã¨ã§ãã
ãããªã£ãå ´åãåä¸ãã¼ã¸ã®ã¢ããªã¨æ¯è¼ãã¦ããã¼ã¸ã®èªã¿è¾¼ã¿æéãé·ããªãã¾ãã
ããã¯ããµã¼ãã¼ãåçã³ã³ãã³ããç¹°ãè¿ãã¬ã³ããªã³ã°ããå¿ è¦ãããããã§ãã
SSRã使ç¨ããå ´åã¯ãå ¨ä½çã«ã¬ã³ããªã³ã°é度ãé ããããã¢ããªã±ã¼ã·ã§ã³ã®UIãé常ã«ã·ã³ãã«ã§ããã¼ã¸ãæ©è½ãå°ãªãããã³ã¢ããªã±ã¼ã·ã§ã³ã®åçãã¼ã¿ãå°ãªãå ´åãæé©ã§ãã
ã¾ããSSRã使ç¨ããã¨ããã¼ã¸ããªãã¼ãããæ°ãããã¼ã¸ã«ã¢ã¯ã»ã¹ããã«ã¯ããµã¼ãã¼ãªã¯ã¨ã¹ããå度ãããããå¿ è¦ãããã¾ãã
ããã«ã¯ããµã¼ãã¼ã®é«ãã¡ã¢ãªä½¿ç¨éã¨é«ãå¦çè½åã®è² æ ãä¼´ãã¾ãã
éçãµã¤ãçæ
éçãµã¤ãçæï¼Static Site Generationï¼SSGã¯ãã¦ã§ããµã¤ãã®ãã¼ã¸ãã³ã³ãã³ããéçºè ããµã¤ãããã«ãããéã«ä¸åº¦ã ãçæããææ³ã§ãã
ããã¯ããã¼ã¸ã1åã ãçæãããã«ãæãã¤ã¾ãããã¸ã§ã¯ãã®ã³ã³ãã¤ã«æã«çæãããã®ãã次ã®å±éã¾ã§ãã¹ã¦ã®è¦æ±ã«å¯¾ãã¦ä½¿ç¨ãããã¨ãæå³ãã¾ãã
SSGã§çæããããã¼ã¸ã¯ããã§ã«äºåã«éçãªãã¡ã¤ã«ã¨ãã¦é ç½®ããã¦ããããããµã¼ãã¼ããã¼ã¸ããªã¯ã¨ã¹ãã«å¿ãã¦åçã«çæããå¿ è¦ãããã¾ããã
ãã®æ¹æ³ã§ã¯ãHTMLãã¼ã¸ãäºåã«ä½æããã¦ã¼ã¶ã¼ãå©ç¨å¯è½ã«ãªãããã«ãã¾ãã
éçºè ã¯ãã³ãã¬ã¼ãã¨ã³ã¸ã³ããã¼ã¯ã¢ããè¨èªã使ã£ã¦ã¦ã§ããµã¤ãã®ãã¶ã¤ã³ãã³ã³ãã³ããè¨è¿°ããããããã«ãã³ãã³ãã«ãã£ã¦éçãªHTMLã«å¤æãã¾ãã
ãã®ããã»ã¹ã¯ä¸åº¦è¡ãããçæãããéçãªHTMLãã¡ã¤ã«ã¯ã¯ã©ã¤ã¢ã³ãã«é ä¿¡ããã¾ãã
çµæã¨ãã¦ãã¯ã©ã¤ã¢ã³ãå´ã§ã¯ãµã¼ãã¼ã«ãªã¯ã¨ã¹ããéããã¨ãªããéçãªHTMLãç´æ¥èªã¿è¾¼ããã¨ãã§ãã¾ãã
SSGã®å©ç¹ã¯å¤å²ã«ãããã¾ãã
ã¾ããéçãªHTMLãã¡ã¤ã«ã¯é«éã«èªã¿è¾¼ã¾ãããããã¦ã¼ã¶ã¼ã¨ã¯ã¹ããªã¨ã³ã¹ã®åä¸ãæå¾ ã§ãã¾ãã
ã¾ããã»ãã¥ãªãã£ã®ãªã¹ã¯ãä½æ¸ãããã¨ãã§ãã¾ãã
ããã«ãCDNï¼ã³ã³ãã³ãããªããªã¼ãããã¯ã¼ã¯ï¼ã®æ´»ç¨ããã£ãã·ã¥ã®æå¹æ´»ç¨ã«ãã£ã¦ãã¹ã±ã¼ã©ããªãã£ã¨ããã©ã¼ãã³ã¹ãåä¸ãã¾ãã
ãã ããå ¨ã¦ã®ãã¼ã¸ã«éçã³ã³ãã³ããé©ç¨ããããã§ã¯ããã¾ããã
ä¸é¨ã®ãã¼ã¸ã¯å®æçãªæ´æ°ãå¿ è¦ã§ãã£ããããã¼ã¿ã®ã©ã¤ãæ´æ°ãå¿ è¦ã¨ãªããã¨ãããã¾ãã
ã¾ããHTMLãCSSãããã³JSãã¡ã¤ã«ãéçãã¡ã¤ã«ã¨ãã¦æä¾ã§ããã®ã¯äºå®ã§ãããJSONãã¼ã¿ã¯å¸¸ã«åçã§ã¦ã¼ã¶ã¼ã«ä¾åããå¯è½æ§ãé«ãããã常ã«API Serverãå®è£ ããå¿ è¦ãããã¾ãã
ã¤ã¾ãããµã¼ãã¼ãHTMLããã¥ã¡ã³ããã¬ã³ããªã³ã°ããããã®APIå¼ã³åºãã¯åºæ¬çã«ã¯è¡ãããªãã¨ãããã¨ãæå³ãã¾ãã
ãã¼ã¸ã¯æ§ç¯æ®µéã§ã¬ã³ããªã³ã°ãããããããã¹ã¦ã®ãã¼ã¸ã¯äºåãã£ãã·ã¥ãäºåçæãäºåã¬ã³ããªã³ã°ããã¦ãããããé常ã«é«éã«èªã¿è¾¼ã¾ãã¾ãã
éçãµã¤ãã®ãã¹ãã£ã³ã°ãµã¼ãã¹ãæä¾ããä¸è¬çãªãã©ãããã©ã¼ã ã«ã¯ãSectionãGitHubãNetlifyãªã©ãããã¾ãã
ãããã®ãã©ãããã©ã¼ã ã使ç¨ãããã¨ã§ãç¬èªã®ãã¼ã¿ãã¼ã¹ã¯å¿ è¦ããã¾ããã
éçãµã¤ãçæãæ´»ç¨ãããã¨ã§ãä¸è¨ã®ãããªãã¹ãã£ã³ã°ãµã¼ãã¹ãå©ç¨ãã¦ãèªåãã«ãã§éçã«çæããããã¼ã¸ãå®è¡ãããã¨ãé常ã«ç°¡åã«ãªãã¾ãã
SSGã¯ãéçã³ã³ãã³ããå¤ãå ´åã«ç¹ã«é©ãã¦ãã¾ãã
è¶ é«éã§éçHTMLãã¡ã¤ã«ã®èªã¿è¾¼ã¿æéãç縮ããããããSEOã©ã³ã¯ã®ã³ã³ãã³ãã«ãé©ãã¦ããã¨èãããã¦ãã¾ãã
3ã¤ã®ä¸»ãªéã
ãCSRã¨SSRã®éãã«ã¤ãã¦ç¥ã£ã¦ãããããã¨ããæ¹ãå¤ããã¨æãã¾ãã
CSRï¼ã¯ã©ã¤ã¢ã³ããµã¤ãã¬ã³ããªã³ã°ï¼ã¨SSRï¼ãµã¼ãã¼ãµã¤ãã¬ã³ããªã³ã°ï¼ã¯ããã¼ã¸ã®ã¬ã³ããªã³ã°ãè¡ãããå ´æã«ããã¦ä¸»ãªéããããã¾ãã
CSRã§ã¯ããã©ã¦ã¶ï¼ã¯ã©ã¤ã¢ã³ãï¼ä¸ã§ãã¼ã¸ã®ã¬ã³ããªã³ã°ãè¡ããã¾ããã¯ã©ã¤ã¢ã³ããµã¤ãã§ã«ã¼ãã£ã³ã°ãåçã«ç®¡çããå¥ã®ã«ã¼ããè¦æ±ãããã¨ãã«ãã¼ã¸ãæ´æ°ãã¾ãã
CSRã¯ãSEOã«é¢ãã¦ã¯åé¡ãçºçãã«ããããªã¢ã«ã¿ã¤ã ãªãã¼ã¿ãå¿ è¦ãªãã¼ã¸ã«é©ãã¦ãã¾ãã
ä¸æ¹ãSSRã¯ãµã¼ãã¼ãµã¤ãã§ãã¼ã¸ã®ã¬ã³ããªã³ã°ãè¡ããã¾ããåçãã¼ã¿ã使ç¨ãããã¼ã¸ã«ãé©ãã¦ãããSEOã«ããã¬ã³ããªã¼ã§ãã
SSRã¯ãªã¯ã¨ã¹ãããããã³ã«ãã¼ã¸ã®ã¬ã³ããªã³ã°ãè¡ããããããã¦ã¼ã¶ã¼ã¨ã¯ã¹ããªã¨ã³ã¹ã®åä¸ã«ä¸å½¹è²·ãã¾ãã
ããã«ãSSGï¼éçãµã¤ãã¸ã§ãã¬ã¼ã·ã§ã³ï¼ãéè¦ãªã¢ããã¼ãã§ããSSGã¯ãµã¼ãã¼ä¸ã§ãã¼ã¸ãã¬ã³ããªã³ã°ãã¾ãããSSRã¨ã¯ç°ãªãããã«ãæã«ãã¼ã¸ãã¬ã³ããªã³ã°ããä¸åº¦ãã«ãããããã¼ã¸ã¯ãªã¯ã¨ã¹ãæã«è¿ããã¾ãã
SSGã¯ä¸»ã«éçãªãã¼ã¸ã«é©ãã¦ãã¾ãããåçãªãã¼ã¿ãå«ããã¼ã¸ãçæã§ããç¹ã§ã便å©ã§ãããã ããå¤æ´ã«å¯¾ãã¦ã¯åãã«ããå¿ è¦ã«ãªããã¨ã«æ³¨æãã¦ãã ããã
CSRã¨SSRãããã¦SSGã¯ãããããç¬èªã®ç¹å¾´ãæã¡ã使ç¨ããç¶æ³ã«ãã£ã¦æé©ãªé¸æãç°ãªãã¾ãã
SEOã«ã¤ãã¦ããCSRã¨SSRã®éã«å®å ¨ãªå·®ç°ãããããã§ã¯ãªãã追å ã®å¯¾çãå¿ è¦ãªå ´åãããã¾ããããã®ããã¬ã¼ãéçºè ã¨ãã¦ã¯ããããã®ã¬ã³ããªã³ã°ææ³ãé©åã«ç解ããç¹å®ã®ããã¸ã§ã¯ãã«åã£ãæé©ãªæ¹æ³ãé¸æã§ããããã«ãªãã¨è¯ãã§ãããã
æå¾ã«
ãµã¼ãã¼ãµã¤ãã¬ã³ããªã³ã°ï¼SSRï¼ã¯ããã«ãæã«éçãªHTMLãçæãã¾ãã
éçHTMLã¯é«éãªåæã¬ã³ããªã³ã°ãå®ç¾ããã¦ã¼ã¶ã¼ä½é¨ãåä¸ããã¾ãã
ããã«ãäºåã«ã¬ã³ããªã³ã°ãããéçHTMLã¯ãWebã¯ãã¼ã©ã¼ã容æã«ã¯ãã¼ã«ãã¦ã¤ã³ããã¯ã¹ã«ç»é²ã§ãããããSEOã«ãé常ã«é©ãã¦ãã¾ãã
ãã ããï¼SSRï¼ã使ç¨ãããï¼CSRï¼ã使ç¨ãããã®æçµçãªæ±ºå®ã¯ãããã¸ã§ã¯ãè¦ä»¶ã¨ãã¼ã ã®æ¹éã«ãããã®ã§ãã
ãããã£ã¦ã両æ¹ã®ã¢ããã¼ããé çªã«è¡ããã¨ãããã¾ãã
æ¬æ¥ã¯3ã¤ã®ä¸»ãªã¬ã³ããªã³ã°ã¢ããã¼ãã説æãã¾ããã
ã©ã®ã¢ããã¼ããå®ç§ã§ãããã¹ã±ã¼ã©ãã«ã§ãã
æ§ç¯ãããã¢ããªã±ã¼ã·ã§ã³ã®ç¨®é¡ã§ãããUIãæ©è½ãWebãã¼ã¸æ°ã表示ããã³ã³ãã³ã(åçãéçã)ã¾ãã¯SEOãèªã¿è¾¼ã¿æéã«å¤§ããä¾åãã¾ãã
ãã®è¨äºããã¬ã³ããªã³ã°ãã©ã¯ãã£ã¹ã®åºæ¬æ¦å¿µãç解ããã®ã«å½¹ç«ã¤ãã¨ãé¡ãã¾ãã
æ¬æ¥ã¯ä»¥ä¸ã¨ãªãã¾ãã
æå¾ã¾ã§èªãã§é ããããã¨ããããã¾ãã
ãã®è¨äºãå½¹ã«ç«ã£ãããããã¯ãã¼ã¯ã¨å ±æããã¦ããã ããã¨å¹¸ãã§ãã