Recent Topics

1 Mar 13, 2007 09:50    

My b2evolution Version: 1.9.x

I found this method of generating static HTML of a blog's main page, but I can't get it displayed: I still get the .php version.

I have a stub file for this particular blog.

Anyone?

2 Mar 16, 2007 07:20

Does the feature actually generate the .html file? If so it'll be up to your server to follow the standard rules and serve up a .html before a .php file if no file is specified.

Basically that means a link to your php file will always go there, but a link with no file (to just your domain name for example) will follow the rules and try to find the file to deliver. So like someone types in your url without a file. I (googled it but can't find and therefore) think that a typical server will look for index.html and serve that up before any other page. After that is index.htm then default.html then default.htm, but somewhere in there the php extensions show up. For some reason I think there are 7 official pages that'll get delivered if no file is identified.

ANYWAY, if you know the .html file is being created on your server try visiting just your domain name (or domain and path-to-blog) and see if it serves up the .html version. You can test it by adding a new post after generating a static page, then trying to visit the static page.

3 Mar 16, 2007 10:13

EdB wrote:

Basically that means a link to your php file will always go there, but a link with no file (to just your domain name for example) will follow the rules and try to find the file to deliver. So like someone types in your url without a file. I (googled it but can't find and therefore) think that a typical server will look for index.html and serve that up before any other page. After that is index.htm then default.html then default.htm, but somewhere in there the php extensions show up. For some reason I think there are 7 official pages that'll get delivered if no file is identified.

It's an Apache setting, that could be overwritten in a .htacess file (if your host allows you to). The sample.htaccess of b2e has the line I mentioned:

# this will select the default blog template to be displayed
# if the URL is just .../blogs/
<IfModule mod_dir.c>
	DirectoryIndex index.php index.html
</IfModule>

The generated file is called a.html (it's the A blog).

It doesn't work for me yet, but probably this is just a cache problem.

Thanks for helping me on track.

4 Mar 16, 2007 10:34

I'm not all that good on .htaccess, but from looking at what you posted I'd guess that you need to reverse the index.php & index.html order

# this will select the default blog template to be displayed
# if the URL is just .../blogs/
<IfModule mod_dir.c>
    DirectoryIndex index.html index.php
</IfModule> 

¥

5 Mar 16, 2007 10:57

¥åßßå wrote:

I'm not all that good on .htaccess, but from looking at what you posted I'd guess that you need to reverse the index.php & index.html order

# this will select the default blog template to be displayed
# if the URL is just .../blogs/
<IfModule mod_dir.c>
    DirectoryIndex index.html index.php
</IfModule> 

¥

Or, in my case, add a.html before that. Come to think: how does this index.html gets there. The index.php is the file that gets it all started by default. Is the index.html perhaps the cached file that is automagically generated by B2e (there is a setting in the Backoffice)? If so I don't need the maually created a.html at all.

Got to go now. Back after the weekend.

Thanks

6 Jul 18, 2007 20:14

Has anyone figured out how to schedule the static generation? I could do with with a wget cron job but I thought someone may already have done this ..

7 Jul 18, 2007 23:08

No, I haven't succeeded any further than this.
A cron job sounds like the best idea, but since it is 'only a link that must be called' to generate a fresh static page, I guess there are other solutions.
This is the link that generates the static html page: h**p://domain.com/admin.php?ctrl=collections&action=GenStatic&blog=2
If you dissect b2evo with this starting point you get to ../blogs/inc/CONTROL/collections/blogs.php from line 258 onward.

Good luck

8 Jul 19, 2007 01:39

It's an Apache setting, that could be overwritten in a .htacess file (if your host allows you to). The sample.htaccess of b2e has the line I mentioned:

# this will select the default blog template to be displayed
# if the URL is just .../blogs/
<IfModule mod_dir.c>
    DirectoryIndex index.html index.php
</IfModule>

[/quote]

All that does is says use look for index.html then index.php for the default page to display, no caching...

9 Jul 19, 2007 02:00

balupton wrote:

All that does is says use look for index.html then index.php for the default page to display, no caching...

When I wrote cache, I meant the Firefox cache, preventing me from seeing the most recent page.
The idea from Mr Cherry is to do a cron job generating a static page every somany minutes or hours. You'll then want to configure .htaccess to display the static html rather than the php file.

10 Jul 19, 2007 02:25

Using virtual hosting, my httpd.conf now looks like this:

<VirtualHost 12.12.12.12>
DocumentRoot "/var/www/somedomain.com"
ServerName somedomain
<Directory "/var/www/somedomain">
DirectoryIndex index.html index.php
allow from all
Options +Indexes
</Directory>

I bet that'd work in a .htaccess too.

Afwas wrote:

This is the link that generates the static html page: h**p://domain.com/admin.php?ctrl=collections&action=GenStatic&blog=2
If you dissect b2evo with this starting point you get to ../blogs/inc/CONTROL/collections/blogs.php from line 258 onward.

\

Extremely helpful, thank you.

After thinking about it, it seems like I could use the events in the Plugin API that fire when a blogger makes a post or somebody comments. If I generate the static file each time somebody posts or comments, that should reduce some of the load on MySQL.

Anybody see any gotchas with this? It seems like a reasonable use of a plugin.

11 Jul 19, 2007 02:27

If you want to prevent browser cache just search for "php no cache headers", there should be a fair few of them.

For the generating cache to use, b2evo already caches post contents, so that's a start, but nothing like a cache everything solution. I guess you would have problems caching the page with special params, eg. category browsing or whatever. But that can be worried about at a later time.

But i guess it would go something like this for just a simple index.php cache.

<?php

// Start of the document, after hit logging
if ( empty($_GET) && empty($_POST) )
{	// We are the standard index.php
	
	$cache_file = dirname(__FILE__).'/index.html';
	$last_write_time = filemtime($cache_file);
	$next_write_time = $last_write_time + (2 * 60 * 60); // two hours in the future
	$write_cache = time() > $next_write_time;
	if ( !$write_cache )
	{	// Use cache
		echo file_get_contents($cache_file);
		die;
	} else
		ob_start();
}

// End of the document
if ( $write_cache )
{	// We are past the last write time, make a new write
	$contents = ob_get_flush();
	file_put_contents($cache_file, $contents);
	die;
}

?>


Form is loading...