During something or another I was doing over the weekend, I noticed that I was running out of disk space again. And that the majority of it was in my blog directly. My blog archives directory, in point of fact (significantly larger than the images directory, which would have been my guess).
I like individual archive entries. It just makes sense to me. I want to keep the Category and Monthly archives, because on occasion it’s nice to see things in those context. But, in point of fact, they take up a minimum of space, vs the 4,500 individual entries I have (yeesh).
But I like individual entries.
So this morning, I downloaded and printed out one of my entries — a short one, in fact, just a few paragraphs long.
The print-out was fifteen pages long. 35Kb in size that bugger was.
All those links and images and other such felgercarb were seriously bloating each and every individual file. Do the math. That’s 156Mb (rounding things off).
So I’ve started using Server Side Includes, extensively. We’ll see how that works out. SSI has include comments in the HTML files pointing to boilerplate text (or scripts, etc.) in other files. Rather than that stuff being duplicated in every single post, it gets slipstreamed into the HTML that gets downloaded from the server to the browser.
So wherever I had blocks of HTML or Java code, etc., that didn’t have any MT template commands embedded in it, I turned it into includes. That was actually pretty easy, since I was already doing a lot of stuff with MTInclude templates; some of those just changed into SSI templates.
Yes, that may take a fraction longer, time-wise. And it increases the server load, too. If I get a nastygram from HostingMatters, I’ll have to reevaluate — but the technique is documented in their online forums.
(And, yes, I guess I could do it with PHP, too. Aside from not wanting to turn all my pages back into PHP pages, though, I’m not sure why I would.)
At any rate, after all that diddling around, that same HTML file? 7Kb. In other words, about 28Kb less. Or, across 4500 posts, about a 126Mb savings.
That gives me a little breathing space again. youbetcha.
Myself, I simply know I should be using more includes in general for the boilerplate code — I’m simply not doing it 🙂 Every blog template is lovingly cut and pasted handcrafted and all that.
Every time I go through a major design overhaul, I make a little more of it ‘generic’, but I’m in no rush, since I don’t use individual entries 🙂
O great lord of webby goodness, teach your deciple. I have no friggin’ clue how to do that and I am on my last 25 MB. Yeesh.
Okay, pretty simple here.
Basically you can include any static text (oversimplifying for this purpose) in your blog through SSI. Let’s say you have a block of code or pictures — okay, take for example the glossary I have on each of my pages. That’s a lot of text (underlying HTML code, comments, etc.), repeated in every individual file.
Instead, put it in its own file — call it glossary.tmpl. (The extension doesn’t make a difference, but it shouldn’t be an executable extension, like .cgi. I use .tmpl for template.)
Then in your MT template where it should go, simply put in:
<!–#include virtual=”/blog/glossary.tmpl” –>
The “/blog/” part is the path to that snipped file, whatever it is on your site. If you leave off the path, the server will assume it’s on the same page.
(Yes, it looks like an HTML comment. Make sure there’s no space between the comment opening and the “#”.)
It’s that simple. When the server goes to feed the HTML file to the browser that is calling it, it spots the includes, plugs them in as it goes, and what the browser sees is the full-blown file. But I only had to put the code out on the server once, rather than 4,500 times.
Again, it has to be static text — or, at least, it cannot have any MT template tags or commands in it; those items get processed during the file builds, not in the server delivery.
Now, you can make use of MT in this through the MT template module system. When you create a template module, there’s a “Link this template to a file” field you can fill in. That’s hwere you can specify that the “glossary” template should sync to the “glossary.tmpl” file (which will go in the root of your blog). As long as there are no MT commands in there, it will work great.
Technically, SSI only works on .shtml files, not .html files. You can get aorund that by modifying the file .htaccess in the directory(ies) that will be using these includes to have the line:
AddHandler server-parsed .html .htm
That will tell the server to look at all .htm and .html files to see if they have server-side stuff that needs to be done. This can create an incremental load on the server, but HostMatters, at least, doesn’t seem to worry about it.
Clear as mud?