0

My website take long respond to load,it is create on Cake PHP.

In my site there is 7 MySql query, when i load the page,7 querys run so it take 5 seconds to 18 seconds and then sever send response in HTML format to browser, and then full page show with in 0.5s. i mean suddenly full page show. ,

my page have five section like header, menu bar, content, side bar and footer,

is this possible that every section load one by one, its look like, when new visitor come, so page response is like that, first head show, then menu, then context, then side bar and at the end footer show.

My domain speed is very fast, my admin panel open in 1 sec, but pages are take long time, so thats why i want to do this, My admin panel is fast but pages take long time to send First Byte.

here is simple code,

<body>
<div class="container">

<?php include("head.php"); ?>

<?php include("menu.php"); ?>

<?php include("content.php"); ?>

<?php include("side_bar.php"); ?>

<?php include("footer.php"); ?>
</div>
</body>

how can i do this, first head.php page and its Mysql query run and server response show in browser

then second part menu.php page and its Mysql query run and server response show in browser,

all other pages that i include in <body> run one by one and result show on browser

so with this decnique visitor wait less,

how can i use AJAX here or and other technique?

Please guide me, may be this technique decrease page load time and First byte response.

thank you

5
  • 1
    Usually slow queries are because you haven't set the indices on the tables. Commented Oct 1, 2013 at 9:53
  • First: Better to optimize your DB or table fetch. Second: Using ajax, you can make the 5 calls, use a var to track what call returns and populate accordingly. But do you need calls to be syncronized? one after another in defined manner? Then better to optimize queries. Commented Oct 1, 2013 at 11:01
  • @jeff now i learn little about index tables, here is query "CREATE INDEX index_name ON table_name (column_name) " is this enough to excute in Mysql or i do some thing more to create a index on table? if this query is not enough so please provide me any link where i understud better index on table Commented Oct 1, 2013 at 14:14
  • here index on page query is. CREATE INDEX index_name ON table_name (column_name). how can i find which column_name i best for index? Commented Oct 1, 2013 at 14:32
  • @Kailash19 i do long research on syncronized, but in google result about syncronized between two table, or syncronized between remote and local server,,, but i have only one localhost, and 25 table,, so how can i apply syncronized here? Commented Oct 1, 2013 at 20:33

1 Answer 1

1

If I understand your query correctly, could you not place the includes inside if statements based on the result from the previous include?

For example if your head.php runs a mysql query called $head_result, you could have:

if (count($head_result) > 0)
{
    include("menu.php");
}

Or something similar

Sign up to request clarification or add additional context in comments.

1 Comment

i want to say that when head.php page load on browser, then menu.php request again go to server and load menu on browser,, all include pages load one by one on browser. previous load then second load

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.