Website PHP Tutorial
Template Website
Business Info
Blogger Templates
Free CSS Template
Online Tools
Do You Want to use our services or want to establish cooperation please contact us on whatsapp +6285244351343

Artikel Terbaru , 2020-02-29

How to use ETAG header on php

PenulisIndra Rani

How to use ETAG header on php

How to use ETAG header on php

Published : 2020-02-29 by Indra Rani | Website PHP Tutorial

How to use ETAG header on php

Sitemap How to use ETAG header on php

hi everybody .  are you currently learning SEO techniques, one of the important things about SEO techniques is about ("server side caching"). well, maybe some of you are still confused about "how to fix the server side caching test cache page" 
Here I share the trick. we will first use the ETAG method. The ETAG method is used on a PHP / Backend website or Server Side system. 
The use of E-TAG. where must be installed you can see below.

Name Page Using ETAG
Index Website Not-recomended
Fixed Page (About us , contact)  Required
Blog Page Required
Images Server side Required
CSS , Javascript code , More files WITH htaccess

That is my suggestion about using ETAG on server side. and for the usage code you can directly attach it to your index but you must set it only for "Page, Image Crop, and blog content", I do not recommend using ETAG on your website index, because the website index is a main page that is always changing every time you make a new post. so you should use ETAG only on pages that don't change at any time.

Code How to use ETAG header on php  

header('Cache-Control: max-age=86400'); / / max-age is convert by seconds 
header('ETag: ' . $code); // you can using ETAG by name on your URL . 

Alternative ETAG header with htaccess

This code is for use on htaccess which is useful for providing cookies on external files, such as CSS, Javascript, HTML, Direct Image, PDF, etc.

<IfModule mod_expires.c> 
 ExpiresActive On 
 # Images 
 ExpiresByType image/jpeg "access plus 1 year" 
 ExpiresByType image/jpg "access plus 1 year" 
 ExpiresByType image/gif "access plus 1 year" 
 ExpiresByType image/png "access plus 1 year" 
 ExpiresByType image/webp "access plus 1 year" 
 ExpiresByType image/svg+xml "access plus 1 year" 
 ExpiresByType image/x-icon "access plus 1 year" 
 # Video 
 ExpiresByType video/mp4 "access plus 1 year" 
 ExpiresByType video/mpeg "access plus 1 year" 
 # CSS, JavaScript 
 ExpiresByType text/css "access plus 1 month" 
 ExpiresByType text/javascript "access plus 1 month" 
 ExpiresByType application/javascript "access plus 1 month" 
 # Others 
 ExpiresByType application/pdf "access plus 1 month" 
 ExpiresByType application/x-shockwave-flash "access plus 1 month" 
<filesMatch ".([eE][oO][tT]|[tT][tT][fF]|[sS][vV][gG]|[Ww][Oo][Ff][Ff]|[Ww][Oo][Ff][Ff]2)$"> 
Header set Cache-Control "max-age=31557600, public" 

<ifModule mod_gzip.c> 
 mod_gzip_on Yes 
 mod_gzip_dechunk Yes 
 mod_gzip_item_include file .(html?|txt|css|js|pl|mp3)$ 
 mod_gzip_item_include handler ^cgi-script$ 
 mod_gzip_item_include mime ^text/.* 
 mod_gzip_item_include mime ^application/x-javascript.* 
 mod_gzip_item_exclude mime ^image/.* 
 mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* 


6 Latest articles

Update your latest information by increasing reading. Knowledge is not everything but everything requires knowledge