WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Concatenate the template files into less php files ? (5 posts)

  1. sabinou
    Member
    Posted 6 years ago #

    Hello,

    Do you know if it is possible to reduce the number of php files that make one's template work, concatenate them, in order to reduce the number of server hits ?

    For instance have index.php and sidebar.php merged into one ?
    Or have header.php and footer.php not as an independant files, but being a part of index.php ?

    Technically, I suppose I could replace a require() with the simple php code for the footer/header/sidebar, but I have no idea if it would work, or if it would cause problems.

    I'd be grateful if you can give me your opinion :)

    In case you wonder why I'm asking that weird question, here's the explanation.
    I have a blog with many visitors (almost 35k unique visitors per day for 135k pages seen), hosted on a mutualized host. For 8$/month that host is extraordinary I think, no downtimes, no issues, very fast for both the database and the files, even with 35 000 visitors per day. For a server holding such traffic on a wordpress platform, most usually I should be paying much more. But there's one limitation, one, that is horribly annoying : the server counts the number of hits your website generates, and it is limited to 400k hits per day.
    I'm already hosting all non-core files (even the smileys) elsewhere, but I still make 10 hits per unique visitor. If I can concatenate my template files, I could avoid a minimum of 3 hits per visitor, which would be enough to sustain more traffic growth in the future.
    That's for the reason behind my question :)

  2. whooami
    Member
    Posted 6 years ago #

    you can do that, yes, just by editing the files (just as you described), but if you actually look at your server logs.. files that are included the normal way theme files are not seen as separate hits to seperate files. Thats NOT how PHP works.

    Ive had wordpress installs hosted on 4 different shared hosts .. have helped countless people with installs on other hosts on other hosts, and have NEVER seen a template file, for instance sidebar.php come up as an extra hit in server logs. Never.

  3. sabinou
    Member
    Posted 6 years ago #

    Thanks for the reply, Whooami :)

    I am a bit skeptical, in regard to this, since the php files are not loaded into the server's RAM, well, they must be loaded by the server each time the template requires them afresh for a new visitor, don't you think ?

    Even if they don't end on my visitor's machines, each time the server reads again a php file, even for his own use, that should be a hit...

    I guess I will have to ask my host :)

  4. whooami
    Member
    Posted 6 years ago #

    skeptical or not, its provable, look at your server logs.Its not a hit. As I said that not how PHP works.

    That is not to say that your super host might not have a different way of calculating what a hit is.

  5. sabinou
    Member
    Posted 6 years ago #

    Haha, I received a reply from my host : for them, a hit is not a file sent externally, this is a file read locally, and this doesn't matter if that file is combined to others bedore sending an html output (that will count as an additional final hit).
    That's their definition, they agreed it wasn't usually understood like that.

    Strangely, my host does NOT sell account extensions, and yet that would be the most logical next step from them.

    Case closed, I note the post as solved, thanks again :)

Topic Closed

This topic has been closed to new replies.

About this Topic