Professional CodeIgniter

(singke) #1

Chapter 9: Security and Performance


288


There are two important things to keep in mind, however. Since not all browsers support Gzip
compression, it will be ignored by those that can ’ t handle it. Don ’ t fret about this, though, because it is
only the really old browsers that don ’ t use HTTP/1.1 or understand the Accept - Encoding header. Here ’ s
a partial list of non - GZIP browsers:

Netscape Navigator 3

Netscape Communicator 4 (but only those before 4.06, and with errors after that version)

Mozilla 0.9 (unless the user manually configures the browser to accept)

Internet Explore 3.x and below

Opera 3.5 and below

Lynx 2.5 and below (some use separate Gzip command lines)

You might look at that list and think to yourself, “ Isn ’ t it time for people to upgrade? ” You ’ d be amazed
at how long people hang on to their favorite browser.

One more thing about compressing: If you have any white space at the end of your scripts, you ’ ll start
serving blank pages. Make sure that you keep the ends of your scripts tidy.

Please note that Gzip compression only affects how quickly a browser accepts and loads content, so it
will not improve your server - side performance.

Caching


CodeIgniter ’ s caching engine allows you to take dynamically created pages and save them in their fully
rendered states on the server, then reuse those fully rendered pages for a specific amount of time. For
example, the first time a user hits a query - intensive page, the page is cached for X amount of time, and
all other visitors use the cached page until the cache expires.

Where are pages cached? Good question. They are written to the /system/cache folder that sits above
your application.

With high - traffic web sites, caching can give you huge boosts in performance in a short amount of time.
To put in caching, all you need to do is set a caching value for any controller function using the following
command:

$this- > output- > cache(X);

where X is the number of minutes you want the cache to remain active before it is deleted and reset.
That ’ s it — there ’ s nothing else to load or configure because caching is part of the Output class and is
therefore ready to be used in your application.

❑ ❑ ❑ ❑ ❑ ❑

Free download pdf