We have a site http://www.trimback.com and it is running very slow for some reason. Is there anyone that can help with this we belive that it is with the .htaccess file but not sure. If you notice it does not pop like other sites. Any tip would be helpfull. Thanks
Try adding the following instructiion in the beginning of your .htaccess file It must compress the content on the fly to improve loading time.
I put it at the top and noting. You know when you navigate throught a site and at one point you hit the back button and ban it goes right back here it reloads and take forever. Any other clues?
I didnt think that the load time was all that bad so maybe you got it fixed but when your pulling that much stuff from other sites its hard to control how bad your load times are sometimes.
OK, your css and html are... hairy. That aside, the main problem is that you should be loading the catalogue content of your site dynamically, using a database of some sort. This will streamline things a lot.
We are using a database. See the crazy thing is that the admin panel is super fast while the front end is just slow as hell here try this page this one takes for ever. http://www.trimback.com/store/amazon-com
It loaded relatively quickly for me (7 seconds). That being said, I checked the site out with Firebug's NET panel (if you don't have it already, check out this tool -- it's a plugin for Firefox and it rocks.) and what I saw as the biggest issue is that you're loading a LOT of things. Your homepage makes 85 different requests (images, css, js, etc etc) Size-wise though, all your images and files are reasonable. And your server is a little slow on first load, which (I think) has to do with where it's hosted and the speed of the server / connection that it is on.
icear The site is hosted at mediatemple.net and they are one of the best. Did you go through the site and then at one point hit the back button thats where it has to reload its got to be instant. And we tried firebug and there really is not much there that will help us out.
If you could find a way to cut back on the redundant span tags and whatnot your site would be faster. You are repeating a lot of the same information. instead of writing out 200 links, put the unique portions of the links in your DB, then, with php, tell ONE COPY, of the link, with your sql referenced via php echo to REPEAT, until the DB runs out of records of until it hits a set limit.
Scratch the db thing, sorry. Try optimizing your css a bit more maybe? image files look fine, but the repetition of the span styles through your site could be slowing it down.
Hi Sam, site loaded in about 6 seconds for me, which isn't too bad considering your homepage HTML has 2536 lines of code! You are also loading a lot of content like images, scripts etc from external sites. When I first loaded the page, it loaded some then, paused for a second or two while it was sourcing an image from Amazon. Your homepage HTML file size is 150kb which in itself is very big! Most JPEG photos online are smaller than that. I would recommend moving more of your inline CSS to your external stylesheets. You need to remove as much of the code as you can. You should also remove your HTML Comments <!-- Twitter --> as an example, these do nothing other than help the web designer, and in your case, i'd trim as much code off as you can.
Ok I just want to say thanks to all that have left a comment to help. This what we have as of now before I posted this the back button would not work but we have it now and what I mean about the back button is when you go past the first page and hit the back button it would take for ever now it is instant what we did is add this code session_cache_limiter('public'); $cache_limiter = session_cache_limiter(); session_cache_expire(30); $cache_expire = session_cache_expire(); Now we have narrowed the problem down to the index.php file and the code is bellow if any one see something wrong or will not allow pages to lode faster please leave a comment we will try just about anything. thanks. <? header('Content-Type: text/html; charset=utf-8'); ob_start("ob_gzhandler"); session_cache_limiter('public'); $cache_limiter = session_cache_limiter(); session_cache_expire(30); $cache_expire = session_cache_expire(); session_start();session_name('s');$settings['user']['id']=0; error_reporting(E_ALL ^ E_NOTICE); require "admin/ver.php"; if (isset($_GET['ver'])) die($settings['ver']); require "includes/Smarty.class.php"; $debug = true; //if($_POST && $_POST['form_action'] != "deal_new" && $_POST['form_action'] != "deal_edit" && $_SESSION['token'] != $_POST['sitetoken']) header ("Location: index.php"); $token = md5(uniqid(rand(), TRUE)); $_SESSION['token'] = $token; require "config.php"; require "admin/ver.php"; require_once('includes/functions/main.php'); $pTimer = new TalkPHPTimer(); $pTimer->start(); connect_db(); $settings = array_merge($settings, GetSettings()); if ($settings['lang']=='en') $settings['lang'] = 'english'; require_once('includes/lang/lang_'.$settings['lang'].'.php'); //$ru = explode('/',$_SERVER['REQUEST_URI']); array_pop($ru); $settings['srv_path'] = implode('/', $ru).'/'; $settings['srv_path'] = str_replace('index.php','',$_SERVER['SCRIPT_NAME']); $settings["templ_path"] = dirname(realpath(__FILE__))."/templates/".$settings["template_name"]; $settings["templ_url"] = "http://".$_SERVER["SERVER_NAME"].$settings['srv_path']."templates/".$settings["template_name"]; $settings["url"] = "http://".$_SERVER["HTTP_HOST"].$settings['srv_path']; $settings["comments_link_path"] = "board/index.php?gettopic="; $settings["comments_link_path"] = ""; $settings["date_format"] = "Y-m-d"; $GLOBALS['settings'] = $settings; require_once('includes/functions/deals.php'); require_once('includes/functions/categories.php'); require_once('includes/functions/stores.php'); require_once('includes/functions/clouds.php'); require_once('includes/functions/clicks.php'); require_once("includes/functions/users.php"); require_once('includes/functions/pagination.php'); require_once('includes/functions/zipcodes.php'); require_once('includes/functions/e-mail.php'); require_once('includes/email/my_smarty.class.php'); require_once('includes/email/mymail.class.php'); require_once('includes/email/email_message.php'); $uSettings = $settings['session']; if($uSettings['output_buffering']==1) ob_start(); //Start Session if($uSettings['session.session_start']){ if($name = $uSettings['session.name']){ session_name($name); } if($expire = $uSettings['session.cache_expire']){ session_cache_expire($expire); } session_start(); $_SESSION['id'] = session_id(); } $user = check_login($uSettings['login_auto_check_cookie']); if($user){ $settings['user']['id'] = $user->get('id'); $settings['user']['name'] = $user->get('username'); $settings['user']['is_admin'] = $user->get('is_admin'); $settings['user']['can_post'] = $user->get('can_post'); $settings['user']['rewards'] = $user->get('rewards'); //## Check for Store Owner $result = mysql_query("SELECT * FROM dc_users_store_owners WHERE id={$settings['user']['id']}"); if(mysql_num_rows($result)>0){ $row = mysql_fetch_array($result); $settings['user']['store_owner'] = $row; //Check if user has a store $result = mysql_query("SELECT `id` FROM dc_stores WHERE owner_id = {$settings['user']['store_owner']['id']}"); if(mysql_num_rows($result)>0) $settings['user']['store_owner']['has_store'] = true; else $settings['user']['store_owner']['has_store'] = false; } } if (isset($_GET['logout'])) { logout(); header("Location: index.php");} //Redirect to login page} if (isset($_GET['login'])) require ("admin/inc/login.php"); $smarty = new Smarty; $LoggedIn = 1; $category_tree = get_ctgs_tree(0,0); $smarty->assign("category_tree", $category_tree); $ctgm = get_ctgs_tree_main(0,0); $smarty->assign("ctgm", $ctgm); include "tmpl_inc/clouds.php"; include "tmpl_inc/top_last_deals.php"; include "tmpl_inc/stores_block.php"; if ($_POST['couponSubmitH']=="couponSubmit") include "tmpl_inc/submit-a-deal.php"; if (isset($_GET['pag'])){ if ($_GET['pag'] == "deals") {include "tmpl_inc/deals.php"; $smarty->assign("what_on", "deals"); } elseif ($_GET['pag'] == "coupons") {include "tmpl_inc/coupons.php"; $smarty->assign("what_on", "coupons");} elseif ($_GET['pag'] == "coupons-stores") {include "tmpl_inc/coupons-stores.php"; $smarty->assign("what_on", "coupons");} elseif ($_GET['pag'] == "coupons-categories") {include "tmpl_inc/coupons-categories.php"; $smarty->assign("what_on", "coupons");} elseif ($_GET['pag'] == "stores") {include "tmpl_inc/stores.php"; $smarty->assign("what_on", "stores");} elseif ($_GET['pag'] == "subscribe") {include "tmpl_inc/subscribe.php";} elseif ($_GET['pag'] == "unsubscribe") {include "tmpl_inc/subscribe.php";} elseif ($_GET['pag'] == "contact_us") {include "tmpl_inc/contact_us.php";} elseif ($_GET['pag'] == "submit_a_deal") {include "tmpl_inc/submit_a_deal.php";} elseif ($_GET['pag'] == "member_area") {include "tmpl_inc/member_area.php";} elseif ($_GET['pag'] == "profile") {include "tmpl_inc/profile.php";} elseif ($_GET['pag'] == "register") {include "tmpl_inc/register.php";} elseif ($_GET['pag'] == "register-store") {include "tmpl_inc/register-store.php";} elseif ($_GET['pag'] == "subscription") {include "tmpl_inc/subscription.php";} elseif ($_GET['pag'] == "manage-store") {include "tmpl_inc/manage-store.php";} elseif ($_GET['pag'] == "login") {include "tmpl_inc/login.php";} elseif ($_GET['pag'] == "sitemap") {include "tmpl_inc/sitemap.php";} elseif ($_GET['pag'] == "adddeal") { include "tmpl_inc/add_deal.php";} elseif ($_GET['pag'] == "home") { include "tmpl_inc/home.php";} elseif ($_GET['pag'] == "submit") { include "tmpl_inc/submit-a-deal.php";} elseif ($_GET['pag'] == "exp-coupons") { include "tmpl_inc/exp-coupons.php";} elseif ($_GET['pag'] == "all-stores") { include "tmpl_inc/all-stores.php";} elseif ($_GET['pag'] == "exp-deals") { include "tmpl_inc/exp-deals.php";} elseif ($_GET['pag'] == "top-deals") { include "tmpl_inc/top-deals.php";} elseif ($_GET['pag'] == "fs-coupons") { include "tmpl_inc/fs-coupons.php";} elseif ($_GET['pag'] == "clearance") { include "tmpl_inc/clearance.php";} elseif ($_GET['pag'] == "local") {include "tmpl_inc/srch-by-zip.php";} elseif ($_GET['pag'] == "vote") {include "includes/functions/vote.php"; die();} elseif ($_GET['pag'] == "getAffForStore") { echo getAffForStore(); die();} } elseif ((isset ($_POST['search_str']) && $_POST['search_str'] != "")||(isset ($_GET['search_str']) && $_GET['search_str'] != "")) {include "tmpl_inc/search.php";} elseif (isset ($_GET['dealID']) && $_GET['dealID'] !="" ) include "tmpl_inc/deal_detailed.php"; elseif (isset ($_GET['pageID']) && $_GET['pageID'] !="" ) include "tmpl_inc/page.php"; elseif (isset ($_GET['storeID']) && $_GET['storeID'] !="" ) {include "tmpl_inc/store_detailed.php"; $_GET['pag']='store';} elseif (isset ($_GET['catID']) && $_GET['catID'] !="" ) {include "tmpl_inc/category.php"; $_GET['pag']='category';} elseif (isset ($_GET['categoryID']) && $_GET['categoryID'] !="" ) include "tmpl_inc/category.php"; elseif (isset ($_GET['redirect']) && $_GET['redirect'] !="" ) include "tmpl_inc/redirect.php"; elseif (isset ($_GET['redirect2']) && $_GET['redirect2'] !="" ) include "tmpl_inc/redirect2.php"; elseif (isset ($_GET['print']) && $_GET['print'] !="" ) include "tmpl_inc/print.php"; elseif (isset ($_GET['save']) && $_GET['save'] !="" ) include "tmpl_inc/save.php"; elseif (isset ($_GET['store_site']) && $_GET['store_site'] !="" ) include "tmpl_inc/store_site.php"; elseif (isset ($_GET['tell-a-friend']) && $_GET['tell-a-friend'] !="" ) include "tmpl_inc/tell-a-friend.php"; elseif (isset ($_GET['tag']) && $_GET['tag'] !="" ) include "tmpl_inc/tags.php"; elseif (isset ($_GET['couponID']) && $_GET['couponID'] !="" ) include "tmpl_inc/coupon_detailed.php"; elseif (isset ($_GET['do']) && $_GET['email'] !="" ) include "tmpl_inc/email_unsubscribe.php"; elseif ($_GET['pag'] == "request_publ_rights") include "tmpl_inc/request_publ_rights.php"; else { include "tmpl_inc/home.php"; $_GET['pag']='home'; $smarty->assign("what_on", "main"); } if ($lang["meta_keywords"] == '') $lang["meta_keywords"] = $settings['mp_meta_keywords']; if ($lang["meta_descr"] == '') $lang["meta_descr"] = $settings['mp_meta_descr']; if ($pTimer->getTime()<4){ $stores = get_storesfrontSeo(); $smarty->assign("stores", $stores); $sql = "select count(id) as cnt from dc_stores;"; $r = mysql_query($sql) or die("Invalid query: " . mysql_error()); $res = mysql_fetch_array($r); $lang['stores_cnt'] = $res['cnt']; $sql = "select count(id) as cnt from dc_deals where type='coupon';"; $r = mysql_query($sql) or die("Invalid query: " . mysql_error()); $res = mysql_fetch_array($r); $lang['coupons_cnt'] = $res['cnt']; $sql = "select count(id) as cnt from dc_deals where type='deal';"; $r = mysql_query($sql) or die("Invalid query: " . mysql_error()); $res = mysql_fetch_array($r); $lang['deals_cnt'] = $res['cnt']; $sql = "select count(id) as cnt from dc_deals where type='deal' and creation_date_dt='".date('Y-m-d')."';"; $r = mysql_query($sql) or die("Invalid query: " . mysql_error()); $res = mysql_fetch_array($r); $lang['dealst_cnt'] = $res['cnt']; } $sql = "select * from dc_htmlblocks order by id DESC"; $htmlblocks = array(); $query = mysql_query($sql) or die("Invalid query: " . mysql_error()); while ($row = mysql_fetch_array($query)){$htmlblocks[$row['id']] = $row;} $smarty->assign("htmlblocks", $htmlblocks); $smarty->assign('exectime', $pTimer->display()." seconds"); $smarty->assign('pag', $_GET['pag']); $smarty->assign("seo_ext", $settings['seo_ext']); $smarty->assign("version", $ver); $smarty->assign("LoggedIn", LoggedIn); $smarty->assign("msg", $lang); $smarty->assign("add_title", $add_title); $smarty->assign("settings", $settings); $smarty->assign("token", $token); $smarty->assign("base_url", "index.php"); $smarty->assign("templ_name", $settings['template_name']); if (isset ($_GET['print']) && $_GET['print'] !="" ) $smarty->display($settings["templ_path"]."/coupon_printable.tpl"); else $smarty->display($settings["templ_path"]."/index.tpl"); ?>
Hi Sam, I think you need to shorten your home page. It is too painful to go down and view the end of the page.
Yeah, it doesn't seem terribly slow. Although it gets a grade C from Y!Slow - developer.yahoo.com/yslow/ I would recommend installing YSlow (needs Firefox and the firebug extension) and trying to implement some of it's suggestions. I think the high number of HTTP requests is probably your biggest issue like icesar says. Combine your java files if you can and minify all your code (remove all the comments and excess whitespace) and see if you can image map any CSS/navigation images etc.