Sage-Code Laboratory

Site Performance

Static websites have advantages and disadvantages. First of all, a static website is very fast. The Browser have a feature, called "web cache" to store content of static web pages locally. After you visit a page first time, you can visit the same page second time at much higher speed. A developer can setup the server to communicate with the Browser the validity period of content by file type. For example, images can expire after 30 days. HTML and can expire after 3 days and CSS can expire after 10 days. This can be controlled for every folder using configuration file .htaccess (for Apache).

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
<IfModule>
## EXPIRES CACHING ##

# Custom /10 days for most static assets
filesMatch ".(jpg|jpeg|png|gif|js|ico|svg)$">
Header set Cache-Control "max-age=2592000, public"
</filesMatch>

HTML Tutorial

Sage-Code tutorials are super fast, have no ads and require no registration.

    

Read next: Template Page