Linux server / centos commands

LINUX COMMANDS

list files and directories and show their permissions

ls -l

to also list hidden files, use:

ls -la

find all files changed at least one day ago but within three days ago

find . -ctime +1 -a -ctime -3

step 3: install bind (DNS software) and enable SELinux

I always like to install bind first, because this allows me to initialize the DNS transfer of my domain(s) name(s) which takes time, after the setup of bind and while waiting for the DNS transfer to occur, i have time to install and configure other things like the server software (apache / nginx) and the database (mysql / mongo db).

check if bind is installed

First check if bind (Berkeley Internet Name Domain is a domain name service software) is not already installed, to get a list of all the installed packages type:

What's new in HTML5

HTML5 Logo

In this second article about HTML5 i try to show some of the things that will change if you decide to use HTML5:

  • what is the difference between HTML4.01 and HTML5
  • attribute quotes syntax
  • self closing tags
  • the type attribute
  • HTML5 outlining

I hope i will be able to answer the questions, what's the difference between HTML5 an previous versions of html? What is new in HTML5? Why do some tags not need any type attribute anymore? What is outlining?

HTML5 and beyond

HTML5 Logo

The history of HTML5

HTML5 is a standard from W3C. The W3C is a consortium of organizations like Mozilla and firms like Google that have an interest in building standards for the Web. But it's not the W3C who started working on HTML5, it's the WHATWG which started working on HTML5 in mid 2004 right after it was founded. The WHATWG is a group of individuals working in the Web Industry which was founded to make the web standards evolve faster. In the beginning of 2006 the W3C took over the WHATWG HTML5 draft an started working on it.

step 2: ensure that your server software is up to date

A tool used on CentOS to update packages is yum. You will use this tool a lot during the next hours, to update packages already installed, download and install new packages. A very nice feature is that yum will automatically resolve dependencies of the packages you want to install and install the dependencies required by the package you have choosen.

Lazyload (Asynchronous loading) your javascript files

An alternative to putting scripts on the bottom, is to lazyload your scripts. To lazyload your scripts there are three ways i want to show you. First you can write your own little script that will asynchronously load your main javascript file by inserting the script tag for that file programmatically. Second possibility is to use a tool like require.js which is an asynchronous scripts downloader. The thrid possibility is the new HTML5 attribute for the script tag that you can use to force the browser to load the script asynchronously.

Lazyloading a javascript file default

You can create your own basic lazyloader yourself. Only a few lines of javascript in the head of your document and your done:


function lazyload() {
    var scriptTag = document.createElement('script'); 
    scriptTag.src = "//my_example.js"; // set the src attribute
    scriptTag.type = 'text/javascript'; // if you have an HTML5 website you may want to comment this line out
    scriptTag.async = true; // the HTML5 async attribute
    var headTag = document.getElementsByTagName('head')[0];
    headTag.appendChild(scriptTag);
}

Optimize browser caching (expires headers)

Expires headers are very important for browser and if set correctly can reduce your websites loading times by a lot. If big files like your scripts, css or a background image don't change very often, setting big expiry times can help your users browsers to keep those file longer in their cache. This will reduce the loading time of the page(s) but also reduce the bandwidth used.

Move scripts to the bottom

It's important to ensure that the javascript file doesn't block the rendering of the page. Often Javascript pages are pretty big, so it can take some time to load it.

But most javascript isn't executed on pageload, therefore at least the scripts that get used by onclicks and other events that may occur later as the pageload, can be put in the file that will be at the bottom.

Gzip components

This can be done on your development machine and you then transfer the files to your production environment. Or you let your production environment gzip the dynamic files on the fly just before they get delivered to the client. Apache as well as Nginx can do this for you. Apache uses the mod deflate module, Nginx has a module that is called HttpGzipModule. Gzipped html pages for example can be transferred a lot faster from server to the client.

Use a Content Delivery Network

This is not an easy task or feasible thing for small websites. Big websites that get visitors from all over the world can benefit a lot from a CDN network. Amazon for example offers a simple to use and pretty cheap CDN called Cloudfront, i use it for this blog to host my static files like javascript and css. Another big name in this business is cloudflare.