Skip navigation

Category Archives: WAMP

What does browser caching means? Answer is save a copy of the web page  visited by the browser for a temporary period.So that any further  access to the same web page does not require the browser to repeatedly collect all the content from the webserver again.But This tends to create problem in case of Dynamic website where content tends to change in minutes time (or even in seconds time).  With browser cache enabled there might be chances that the old content is shown in the same page wheres the previous content has already been updated. There are two ways you can prevent a browser from caching a web page.

1. Meta tags

We use the following lines of htl code to prevent the browser from caching.

<meta http-equiv="expires" content="Fri, 05 Dec 2008 01:00:00 GMT"/>
<meta http-equiv="pragma" content="no-cache" />

This tells the browser that the cached copy of the we page is already  out of date. hence the on reaching this tag the browser will prevent itself from caching the page. The http-equiv=”pragma” plays the same role but is guaranteed to work on different browsers.

2. HTTP Headers

The other way around would be through the dynamic scripting language (like PHP)  header functions (Cache-Control) as shown below.HTTP 1.1 compliant browsers.

<?php
header('Expires:
Fri, 05 Dec 2008 01:00:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', FALSE);
header('Pragma: no-cache');
?>

smarty
I always had a hard time installing smarty template engine for PHP on xampp or wamp. As there are loads of articles on linux smarty installation. But I was finding it hard to find one for Windows.  Here is the detail procedure. The following article is partly adopted from http://news.php.net/php.smarty.dev/2703

1. Download smarty template engine pachake from here

2. Create a folder smarty outside www or htdocs folder and extract the content of Smarty.x.x.x tothe same  smarty folder.

for example C:\xampp\smarty

3. Now edit ypour php.ini file and edit the include library path add the location path of smarty libraries.

for example: include_path = “.;C:\xampp\smarty\libs”

4. Now we have set the library paths. Next is to set the template and cache folders.

Now create a additional smarty folder inside your www or htdocs  ( This is in different from the smarty package folder outside )  and  create two folders templates and configs inside of it.

example: C:\xampp\htdocs\smarty\templates and    C:\xampp\htdocs\smarty\configs

5. In the outside smarty folder containing the whole package create two folders templates_c and cache .

so that it reads as C:\xampp\smarty\templates_c and C:\xampp\smarty\cache.

6. Now your smarty installtion is done. to test create two scripts index.php and index.tlp . Place index.php in your root folder  and index.tpl inside of C:\xampp\htdocs\smarty\templates and copy the following code in to it.

(Please take care of the single quotes in the code below while copying it for your use)
index.php

<?php

// load Smarty library
require(‘Smarty.class.php’);

$smarty = new Smarty;

$smarty->template_dir = ‘C:/xampp/htdocs/smarty/templates’;
$smarty->config_dir = ‘C:/xampp/htdocs/smarty/config’;
$smarty->cache_dir = ‘C:/xampp/smarty/cache’;
$smarty->compile_dir = ‘C:/xampp/smarty/templates_c’;

$smarty->assign(‘name’,’memohnish!’);
$smarty->display(‘index.tpl’);

?>

index.tpl<html>
<body>
Hello, {$name}!
</body>
</html>

and run the index.php in your browser and you should see the desired output