user3545779
user3545779

Reputation: 97

Include redownloading PHP

I have my banner and navigation in banner.php! So If I need to call it on every page, I should use include 'banner.php';

<html>
<body>
  <div class="wrapper">
  <?php include 'banner.php'; ?>   
  <h1>Login Successful <?php echo $_SESSION['username']?></h1>
  </div>
</body>
</html> 

But this will do re-downloading of the elements of the banner.php. Whenever I try to navigate from one page to other.. every time it will be called and elements will be downloaded..

is it possible to avoid re-downloading and keep the navigation static(means it won't refresh or reload)...??

Upvotes: 0

Views: 29

Answers (2)

nstCactus
nstCactus

Reputation: 5183

It would be possible using frames but this has been deprecated for quite a while now and I discourage you to use that. Another solution would be to use AJAX to only load and refresh the content part of your page (keeping the banner or whatever you like). For most project the best would be to just let the browser cache works its magic.

Upvotes: 1

Mindeater
Mindeater

Reputation: 322

You can invest your development time in a client side framework like AngularJS to create a single page App which repopulates the DOM with AJAX.

Or just let the browser deal with caching your reused elements

Upvotes: 2

Related Questions