Search code examples
phpssi

Combining PHP & SSI?


I have a simple goal but I'm having some issues. To save on bandwidth, I'm attempting to make "index.php" load up the separate parts of the page and then when people select areas of the site from the navbar, JUST the middle content changes.. As it stands, the files just have an echo statement to see if anything shows up - but nothing so far. I read about server side includes but I thought that I might be able to do it strictly with PHP. Is this a proper way to address my goal? What am I missing here? Do you need more info? Thanks so much for your time and help! :D

index.php

<html>
<body>
<?php include 'header-navbar.php' ; ?>
<?php include 'content.php' ; ?>
<?php include 'footer.php' ; ?>
</body>
</html>

Solution

  • You are kind of mixing concerns here. PHP shouldn't be concerned about the display on the client. That is the job of the HTML, JS, CSS, etc. To achieve what you are asking for you should read up on AJAX. It will allow you to load / reload specific sections of the page on the client without refreshing the entire page.

    The thing you need to keep in mind is that regardless of what you cache at the server the same content is going to be sent back for the page. Anything you cache on the server side will have no effect on the amount of bandwidth used to load the page.