Gossamer Forum
Home : Products : Gossamer Links : Discussions :

pros / cons static or dynamic or mod_rewrite

Quote Reply
pros / cons static or dynamic or mod_rewrite
What are the benefits / advantages for running a G Links site in static or dynamic mode?

Dynamic mode: is this using 'mod_rewrite' or are they 2 seperate modes of operation?
Colin Thompson
Quote Reply
Re: [colintho] pros / cons static or dynamic or mod_rewrite In reply to
Hi,

Dynamic mode (in conjunction with mod_rewrite) really just means that a site can run via page.cgi (instead of having to build statically)

This has a couple of advantages:

1) No more builds, ever Smile
2) You have more power in the template. For example:

<%if user.Username%>
show something ONLY for users logged in
<%endif%>

The above code would obviously not work with static pages, as the user variables would not exist when the pages are built.

We do all of our site via mod_rewrite, and I've never had a problem with it.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] pros / cons static or dynamic or mod_rewrite In reply to
Andy

thanks for the quick reply.

If I wanted to change an existing site from 'static' to dynamic with mod_rewrite

What would the process be?

Would I need to change any of the existing pages / templates?

The site is 'static' with a few dynamic pages for about us / privacy etc (called by page.cgi?p=.......)

Thanks
Colin Thompson
Quote Reply
Re: [colintho] pros / cons static or dynamic or mod_rewrite In reply to
Hi,

For the basics, its as simple as uploading a correctly configured .htaccess file :)

For stuff like page.cgi?p=something, you could use:

Code:
RewriteRule p-(.+).html /cgi-bin/links/page.cgi?p=$1 [L]

..and then call the pages with:

p-page_name.html

The main issues you are likely to come across, are CSS/JS/images trying to be processed by the mod_rewrite (this only really comes as a problem, if you categories are like domain.com/Something, instead of domain.com/Something/ or domain.com/Something/index.html)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] pros / cons static or dynamic or mod_rewrite In reply to
The site in question is on a virtual server account used for hosting a few other sites

The .htaccess file, is this just for this site?

Is the mod_rewrite / htaccess file applicable to each site or does it work for all sites on the server?

Thanks
Colin Thompson
Quote Reply
Re: [colintho] pros / cons static or dynamic or mod_rewrite In reply to
Hi,

Have you actually done any research into this? Tongue

A .htaccess file is ONLY for the site you set it up on (normally, you put the file in the www or public_html folder).

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] pros / cons static or dynamic or mod_rewrite In reply to
Thanks for the advice.

I have done a little but of 'research' but I wasnt 100% sure and if I was going to try this I just wanted to have some guidance to ensure that I wasn't starting with a misunderstanding of where the file goes.

I have previously used .htaccess for 'password' protection and just wasnt sure if this was the same file?

I had also seen htaccess 'config' file mentioned and that this would 'restart' the server???

So I was concerned that I could be making a mistake.

Its good that you are here to provide some good info / advice.

Thanks again.
Colin Thompson
Quote Reply
Re: [colintho] pros / cons static or dynamic or mod_rewrite In reply to
Hi,

This should help with the mod_rewrite codes you need:

http://www.gossamer-threads.com/...i?post=269599#269599

Change:

/cgi-bin/page.cgi

..to the path to page.cgi on your site. i.e maybe:

/cgi-bin/links/page.cgi

..or whatever.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] pros / cons static or dynamic or mod_rewrite In reply to
Andy

thats great

most pages / categories appear to work (trying out on 'development/test site)

How should these 'extra' pages that I have be configured?

when I try to reach this page: http://www.mysite.com/...in/page.cgi?=privacy

This works ok if I use the 'dynamic' url above (which is no problem)

But from earlier I interpretted this: and then call the pages with somethin like this: p-page_name.html

This is in the .htaccess file: RewriteRule ^(.*).html /cgi-bin/page.cgi?g=$1.html [L]

to mean that I should use something like: http://www.mysite.com/privacy.html

This didnt work for me - am I misunderstanding somthing here?
Colin Thompson
Quote Reply
Re: [colintho] pros / cons static or dynamic or mod_rewrite In reply to
Hi,

You need to add this line, quite near the top of the .htaccess file (so it gets interpreted early)

RewriteRule p-(.+).html /cgi-bin/links/page.cgi?p=$1 [L]

Then call with:

http://www.site.com/p-privacy.html

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] pros / cons static or dynamic or mod_rewrite In reply to
just a question about running 'mod_rewrite' using the .htaccess file

Whilst looking for info about running 'mod_rewrite' using .htaccess file for a website I found an article on http://apache.org stating that the preffered way of using '.htaccess' files would be in the main server config file as using it in the root of a domain / folder effected server performance. see this page: http://httpd.apache.org/.../howto/htaccess.html

This is part of what this page says: .....in general, use of .htaccess files should be avoided when possible. Any configuration that you would consider putting in a .htaccess file, can just as effectively be made in a <Directory> section in your main server configuration file.......

the .htaccess file is loaded every time a document is requested.........note that Apache must look for .htaccess files in all higher-level directories, in order to have a full complement of directives that it must apply. (See section on how directives are applied.) Thus, if a file is requested out of a directory /www/htdocs/example, Apache must look for the following files:

/.htaccess
/www/.htaccess
/www/htdocs/.htaccess
/www/htdocs/example/.htaccess

And so, for each file access out of that directory, there are 4 additional file-system accesses, even if none of those files are present.............

How would I configure 'mod_rewrite' rules in the main server httpd.conf file?

Can this be configured for individual domains hosted on the same server?

Thanks
Colin Thompson
Quote Reply
Re: [colintho] pros / cons static or dynamic or mod_rewrite In reply to
Hi,

You would need to do it in the httpd.conf file (or the domains seperate .conf file), and put it inside the <VirtualHost> directive.

However, there is no reason you need to do this - AFAIK, there are no performance improvments in doing this - and it just makes you life harder to update the rewrite rules if you want to add more rules ;)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] pros / cons static or dynamic or mod_rewrite In reply to
After 14 days of monitoring my website this is what I found regarding 'site performance'

I had noticed a 'visible slowdown' in page load time, so I checked the site performance statistics for 'page load time' using Google webmaster tools, this is what I found.

Page load times (approx):

static site: 450 milliseconds
mod_rewrite: 950 milliseconds

For the time being, I've turned the 'mod_rewrite' off.

Has anybody else noticed this kind of slowdown when using 'mod_rewrite' ??

Thanks
Colin Thompson
Quote Reply
Re: [colintho] pros / cons static or dynamic or mod_rewrite In reply to
Hi,

Its probably just your server isn't very good ;)

We have a dedicated server with about 100 odd sites on it , and havn't noticed a slow down at all.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] pros / cons static or dynamic or mod_rewrite In reply to
How can you tell if its a 'good server' ??

This site is 'supposed' to be on a 'dedicated server' ??

Although, the hosting company then explained that it was a 'dedicated virtual server' (after I had signed a contract )

I always thought that dedicated was 'standalone' hardware, but they told me that the 'server / hardware' hosts multiple servers, each being a 'dedicated server'

Have I been 'mislead' or have I misunderstood the 'dedicated server' terminology?

'Im NOT happy with the hosting company!!!'

I just got this:...

I would expect the reduction in performanc is because your using a shared service, higher cpu latencies are to be expected when using a virtual server.
In order to reduce this type of latency you would need a CPU that is dedicated just to your server, the way that one would do that is to obtain a dedicated server instead of a virtual one.


Thanks
Colin Thompson

Last edited by:

colintho: Dec 6, 2008, 4:08 AM
Quote Reply
Re: [colintho] pros / cons static or dynamic or mod_rewrite In reply to
Hi,

Quote:
How can you tell if its a 'good server' ??

Well, if it runs ok - it should be fine (a few hundred ms doesn't make a huge difference)

Quote:
This site is 'supposed' to be on a 'dedicated server' ??

Although, the hosting company then explained that it was a 'dedicated virtual server' (after I had signed a contract )

I always thought that dedicated was 'standalone' hardware, but they told me that the 'server / hardware' hosts multiple servers, each being a 'dedicated server'

Have I been 'mislead' or have I misunderstood the 'dedicated server' terminology?

Sounds more like a VPS (Virtual Private Server)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] pros / cons static or dynamic or mod_rewrite In reply to
I think you are right, I've logged into my account and it does say 'virtual server'

I'm paying £65 month, which I'm sure I was told it was for a dedicated server??

I have paperwork / contract which lists this as the server: 1 x Dual CPU Dual Core AMP Opteron 512MB Ram 40GB HDD

I need to speak to the hosting company on Monday!!
Colin Thompson
Quote Reply
Re: [colintho] pros / cons static or dynamic or mod_rewrite In reply to
Ya, sounds like someone is telling porkies - or they intentionally mis-lead you. Still, as you said - best to talk to them on the phone on Monday.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [colintho] pros / cons static or dynamic or mod_rewrite In reply to
I do not use mod_rewrite because it interferes with other stuff I have going on with my server.

Virtual servers

I have the Red Hat Enterprise Linux ES 3 server and it uses virtual servers to set up the different domains on my dedicated server.

In other words in my webman you can set up virtual servers on your dedicated server, which is probably what you have going on.

I have read mod_rewrite is faster and more efficient but I did not see the difference, also MySQL is in the process of giving it more query muscle per an article at: http://www.informationweek.com/...eport_opensource.htm


hope that helps


Sandra Roussel
Chonsa Group Design - Fresh Start Housing
Quote Reply
Re: [colintho] pros / cons static or dynamic or mod_rewrite In reply to
Using dynamic mode with mod_rewrite is obviously going to be slower than serving static files. Whether or not it will be noticeable depends on your server. An average load time of 450ms is pretty bad for static pages, so making your server generate pages on the fly is going to be visibly slower. As a comparison, two dynamic glinks installs that I've been working on running in CGI mode have an average download time (stats from Google webmaster tools as well) of 345ms and 405ms.

Re-reading your post. It isn't mod_rewrite that's slowing things down, it's your webserver needing to run the code to generate the page that's slowing things down (which is normal).

Adrian