PHPã§gzipå§ç¸®ããæ¹æ³ãâ¬â¬æ¥µéã¾ã§ã®å§ç¸®ãããã¦è¡¨ç¤ºæéã¸ã®éã®ãã¾ã¨ã
ä¹ ãã¶ãã«æ°ããwebãµã¼ãã¹ä½ããã¨ç«ã¡ä¸ããâªãJudgeãâ¬ã¾ãããã¡ãã£ã¢å½¢å¼ã®ãµã¼ãã¹ã¨ãã¦åºçºãã¾ããããã®ãµã¼ãã¹ã¯Sharetubeã§ãã¡ã ã£ããã¤ã³ããå¾¹åºçã«æ½°ãã¦ãããã¨ã²ã¨ã¾ãå§ç¸®é¢é£ãããã¾ããã®ã§å¿åé²ã¨ãã¦ããã«ç½®ãã¦ããã¾ãã
å§ç¸®ã®å ¨ä½å³
åºæ¬ã¯gzipã使ç¨ãã¦å§ç¸®ãè¡ãã¾ãããcssãhtmlãå§ç¸®ããåã«ç¡é§ãªæ¹è¡ãªã©ãçãã¦å§ç¸®ããã¦ãã¾ãã
ã»csså§ç¸®
ã»htmlå§ç¸®
ã»gzipå§ç¸®(htmlãgzãã¡ã¤ã«çæ)
ã»ãã£ãã·ã¥
ã»ç»åå§ç¸®
ãã®5ç¹ã§è¡¨ç¤ºæéãç®æãã¾ãã
csså§ç¸®
èªã¿è¾¼ã¿ããcssãå¤æ°åãã¦åä½ããã¤ã¤å§ç¸®ãã¦ããã¾ãã
// èªã¿è¾¼ã¿ããcssãå¤æ°å$core_css = file_get_contents(PATH."assets/css/core.css");
$common_css = file_get_contents(PATH."assets/css/common/common.css");
$matome_css = file_get_contents(PATH."assets/css/matome/common.css");
$css = $core_css.$common_css.$matome_css;
// csså§ç¸®
$css = preg_replace;
// ã³ãã³ã®å¾ã®ç©ºç½ãåé¤ãã
$css = str_replace;
// ã¿ããã¹ãã¼ã¹ãæ¹è¡ãªã©ãåé¤ãã
$css = str_replace( array("
", "", "
", " ", " ", " ", " "), "", $css);
ããã§ã²ã¨ã¾ãå§ç¸®ããcssãå®æãã¾ããã
htmlå§ç¸®
ä¸è¨ã§å§ç¸®ããcssãå·®ãè¾¼ã¿ã¤ã¤å§ç¸®ãããhtmlãå¤æ°ã«å ¥ãã¦å§ç¸®ãã¾ãã
$gzip_article_html = ä¸è¨ã§å§ç¸®ããcssãå·®ãè¾¼ã¿å§ç¸®ãããhtmlãå
¥ãã;
// HTMLå§ç¸®
$search = array(
"/>[^S ]+/s", // strip whitespaces after tags, except space
"/[^S ]+
"/(s)+/s" // shorten multiple whitespace sequences
);
$replace = array(
">",
"<",
"\1"
);
$gzip_article_html = preg_replace;
ããã§ã²ã¨ã¾ãå§ç¸®ããhtmlãå®æãã¾ããã
gzipå§ç¸®
å§ç¸®ããããhtmlãæ´ã«gzipã«ã¦å§ç¸®ãã¦æéãçãã¾ãããã
// articleãã¡ã¤ã«çæfile_put_contents;
$file_org = çæãããå ´æ/index.html";
$file_gzip = $file_org.".gz";
// å
ãã¡ã¤ã«ã®å
容ãèªã¿è¾¼ã
$code = file_get_contents($file_org);
// gzipå§ç¸®å¦çãã¦åä¸ãã©ã«ãã«ãã¡ã¤ã«ãä½æ
$gzip = gzopen($file_gzip ,"w9");
gzwrite($gzip ,$code);
gzclose($gzip);
é¢æ°ï¼gzopen($file_gzip ,"w9");ã®w9ã¨ããç®æã1ã9ã«ããã¨å§ç¸®çãå¤ããã¾ãã®ã§æé©ãªå§ç¸®çã«ãã¾ããããããã§index.htmlã¨index.html.gzãçæããã¾ã
ããã ãã§ã¯åãã¾ããã®ã§ä¸è¨ã«æ¸ããå 容ãå¿ããªãã§ãã ãããã
.htaccessã§gzipãå©ç¨å¯è½ã«ãã
RewriteEngineãOnã«ãã
Options +FollowSymLinks
å
é¨ãã£ã¬ã¯ããªé表示
Options -Indexes
RewriteEngine on
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{REQUEST_FILENAME}.gz -s
RewriteRule .+ %{REQUEST_URI}.gz
ForceType text/css
AddEncoding x-gzip .gz
ForceType application/x-javascript
AddEncoding x-gzip .gz
ForceType text/html
AddEncoding x-gzip .gz
(.php) ForceType text/html
AddEncoding x-gzip .gz
.htaccessãä½æãã¦ä¸è¨ã®å 容ããã¼ã¹ã¨ãã¦ä¿åããã°gzipã¯åãããã«ãªãã¾ãã
.htaccessã§ãã£ãã·ã¥å©ç¨å¯è½ã«ãã
Expires ãæå®ããæ¹æ³
ExpiresActive On
Off
å
¨ã¦ããã£ãã·ã¥ãã
ExpiresDefault "access plus 1 days"
HTML
ExpiresByType text/html "access plus 7 days"
Favicon
ExpiresByType image/vnd.microsoft.icon "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 month"
CSS
ExpiresByType text/css "access plus 1 year"
JavaScript
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType application/x-javascript "access plus 1 year"
ExpiresByType text/javascript "access plus 1 year"
ç»åãåç»
ExpiresByType audio/ogg "access plus 3 month"
ExpiresByType image/bmp "access plus 3 month"
ExpiresByType image/gif "access plus 3 month"
ExpiresByType image/jpeg "access plus 3 month"
ExpiresByType image/png "access plus 3 month"
ExpiresByType image/svg+xml "access plus 3 month"
ExpiresByType image/webp "access plus 3 month"
ExpiresByType video/mp4 "access plus 3 month"
ExpiresByType video/ogg "access plus 3 month"
ExpiresByType video/webm "access plus 3 month"
ãã¼ã¿ã¯ãã£ãã·ã¥ãããªã
ExpiresByType application/json "access plus 0 seconds"
ãã£ãã·ã¥ã«é¢ãã¦ã¯è²ããªæ¹æ³ãããã¾ãããä»åã¯.htaccessã§ExpiresActiveã®onã«ãã¦æ§ã ãªã³ã³ãã³ãæ¯ã«ãã£ãã·ã¥ãæå®ãã¦ãã£ãã·ã¥ãæå¹åãã¾ããã
ç»åå§ç¸®
ç»åå§ç¸®ã«é¢ãã¾ãã¦ã¯æ¢ã«è¨äºãæ¸ãã¦ãã¾ãã®ã§ãã¡ããåèã«ãã¦ãã ããã
ç»åå§ç¸®ãã¼ã«jpegoptimã¨pngquant ã¤ã³ã¹ãã¼ã«ã¨ä½¿ãæ¹
http://sharetube.jp/article/7175/
Sharetubeã¯æ¯æ¥è¨äºãéç£ããããã®ä¸ã§å¤ãã®ç»åã使ç¨ããã¦ãã¾ãããã¼ã¸ãé ãå¤ãã®è¦å ã¯ç»åç³»ã»åç»ç³»ã®ã³ã³ãã³ãã§ãã®ã§ããã®é¨åã軽éåãããäºãã§ããã°ãµ...
ãã¼ã¸ã¹ãã¼ãã調ã¹ãäºãã§ãããPageSpeed Insightsã
ä»åæ½çãæ½ãããµã¤ãâªãJudgeãâ¬
åã¯ã©ã£ã¡ï¼ãæ°ã«å ¥ãã®1çªã決ããã-Judge(ã¸ã£ãã¸)
åã¯ã©ã£ã¡ï¼ãæ°ã«å ¥ãã®1çªã決ããã
æå¾ã«
å ¨ã¦ã®æ½çãè¡ãã¨ã»ã»ã»ãPageSpeed Insightsãã§ã®è©ä¾¡ã¯ã¢ãã¤ã«ã»PCå ±ã«65ãã100ã«ãªãã¾ããçéãµã¼ãã¹ã«ãªãã¾ããã®ã§SEOã®è¦³ç¹ãããæå¾ ã®ã§ããçµæã¨ãªãã¾ããã