Servage Magazine

Information about YOUR hosting company – where we give you a clear picture of what we think and do!

Archive for the ‘Tips & Tricks’ Category

Validate your code for a better web

Wednesday, September 12th, 2018 by Servage
The problem isn't new, but it's still present. Standards and best practices have not just been invented for fun, or mere entertainment for nerds. They actually fulfill rather important purposes. Without standards and best practices, we wouldn't know how we should do things. Without compliance to the defined rules there would be chaos. Or actually, there is chaos... Because the standards and best practices for the web are not being followed completely at all. The World Wide Web Foundation is responsible for the definition of such rules, and continuously works to improve and strengthen the possibilities for web developers, by providing a flexible, yet standardized compendium of possibilities. However, even though ...

Speed up your website – Part 6: Cookies & Mobile

Wednesday, July 25th, 2018 by Servage
This is the sixth and last part of a simplified explanation of the “Yahoo best practices for speeding up your web site“. Read the fifth part here. The fourth part is about image related optimization. Reduce cookie size Basically cookies consume resources in terms of data in requests. The article "When the cookie crumbles" by Tenni Theurer and Patty Chi provide the following conclusions: Don't use unnecessary cookies. Think before storing useless data. Reduce cookie size to the minimum required. It helps response times. Restrict cookies to domains appropriately, so they are not affecting other subdomains unnecessarily. Set appropriate expire dates, to remove cookies as early as possible with regards to their relevance. Do ...

Speed up your website – Part 2: Server

Thursday, July 5th, 2018 by Servage
This is the second part of a simplified explanation of the "Yahoo best practices for speeding up your web site". Read the first part here. The second part is about server related optimization. I am aware that some settings are not available to all developers, depending on their development and deployment infrastructure. Use Content Delivery Networks Where possible you should take advantage of servers closer to your users than your own. TO get started quickly with some major improvements, try to load JavaScript sources like Google APIs, jQuery or similar code you might use in your project, directly from their servers, or suggested CDN. Add expires header to utilize ...

Speed up your website – Part 1: Content

Sunday, July 1st, 2018 by Servage
There are many ways to improve website performance. The "Yahoo best practices for speeding up your web site" is a very comprehensive guide to optimizing many factors of your website. However, the article is very long, and sometimes quite hard to understand, because the technical level of the article is high. Therefore I have collected the main tips of the optimization guide, and will present them in a series of more comprehensible articles. Make fewer requests Each page often contains multiple resources, which each generate a request. For example a basic HTML page with a CSS stylesheet and 5 images, generates a total of 7 request (one for the HTML, ...

Send PHP errors per mail

Monday, June 25th, 2018 by Servage
Error-handling in PHP can be complex, and getting a good way of having clear and good error reporting and maintaining security, by not displaying to much to the public, can be difficult. Maybe sending errors to developers per email could be a good tool for you. Check out the following example code: // Our custom error handler function nettuts_error_handler($number, $message, $file, $line, $vars) { $email = " <p>An error ($number) occurred on line <strong>$line</strong> and in the <strong>file: $file.</strong> <p> $message </p>"; $email .= "<pre>" . print_r($vars, 1) . "</pre>"; $headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Email the error to someone... error_log($email, 1, '', $headers); // Make sure that you decide how to respond to errors (on the user's side) // Either ...

Remember to use secure passwords

Monday, June 4th, 2018 by Servage
It seems that the increasing amount of accounts, logins, services, increases the amount of passwords to keep in mind dramatically. All too often you see people using too simple, or same passwords, for many important services. Therefore I would like to remind about the importance of secure passwords, like in a previous article here on the Servage Magazine. It's important to keep focus on this issue, so users are always reminded to increase their personal level of security. It’s easy for service providers to ask their users to use secure passwords. After all it is the user who is supposed to remember it. Obviously it is better for everyone if secure ...

Create nicer looking forms with CSS

Monday, May 28th, 2018 by Servage
Forms are one of the commonly used elements in HTML. It's a basic functionality for most websites to capture specific information via user input through HTML forms. So why do so many forms look really boring? Why are businesses still missing out on new customers because of unappealing order forms? It's amazing what you can accomplish with form design. It looks good, gives a serious impression, and attracts users. Examples The images illustrating this article are two examples of beautiful order forms I've found online. They are integrated with the rest of the website design, they have a simple layout, there isn't too much data to be added. Users are unlikely ...

Blueprint CSS Framework makes CSS styling easy

Monday, May 21st, 2018 by Servage
The last post about nicer forms introduced some simple CSS tricks to get nice looking forms. It also mentioned the Blueprint CSS framework, which is pretty nice. Blueprint is basically just a set of stylesheets (.css files) that you can include in your website to get certain default design and layout functionality. Why is this great? You often want to do similar things with your web projects in terms of design. Blueprint offers help with exactly that. It makes your standard pages look good, and gives you a great starting point for further customization. It's much better than using the various browsers' own default styling. The features CSS reset of styles to ...

Code tips for .htaccess files

Monday, May 14th, 2018 by Servage
The .htaccess files are often underrated and forgotten, but they do have great powers to manipulate your web server. It's possible to set and change various server settings, for example the Apache configuration. Thereby you can have individual configurations based on files in folders, rather than configuration files that require server restarts to take effect. You can also change settings for plugins, like PHP settings. I've stumbled over a few great .htaccess snippets here, which I found quite useful and wanted to share.

PHP-like in_array function in JavaScript

Monday, April 30th, 2018 by Servage
Recently I once more found myself in a situation where I really felt that I am a PHP-developer, more that a JavaScript-developer. Do you also find your self writing stuff like in_array() in JavaScript code? It happens often to me, that I take for granted in other languages, what I know and love in PHP. It also often takes quite a while to find a good alternative for missing functions in JavaScript, since Google often provides you with multiple options. One of the common functins I miss in JavaScript from PHP is in fact the "in_array"-function. Luckily there is a splendid JavaScript snippet here: function in_array (needle, haystack, argStrict) { ...