Forum Moderators: phranque

Message Too Old, No Replies

htaccess to big

file to big

         

RP_Joe

7:38 am on Jul 9, 2010 (gmt 0)

10+ Year Member Top Contributors Of The Month



I have a site that is using a shopping cart that is writing a big file. It appears to write (rewrite) a line every time a new shopping cart page is created. The SEO file name of the HTML looks great, but the price is a rewrite for every page from the php catalog page. There are 2,600 entries and growing. The file size is 181k.

And if that is not enough, we have 800 redirects needed from the old system because of links.

Pingdom reports a site speed of 9-14 seconds. WMT says it is 8 seconds 30 days ago.

What to do?
What are the possible solutions?

jdMorgan

4:48 pm on Jul 10, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Optimize the existing code. Auto-generated code is usually awful.

Buy a better plug-in for the cart. The plug-in script itself should be accepting "friendly URL" requests, and converting them to form needed by the main script by doing a database lookup.

You might consider posting a few (like six) different samples of the per-cart-page rewrite rules that are being created, just for a quick look...

Jim

RP_Joe

6:19 am on Jul 12, 2010 (gmt 0)

10+ Year Member Top Contributors Of The Month



Thanks Jim

RewriteRule^contents/en-us/animal-fancy-dress-costumes\.html$index.php?p=catalog&catalog_code=1-10-1&%{QUERY_STRING} [L]
RewriteRule^contents/en-us/animal-fancy-dress-costumes-([0-9]*)\.html$index.php?p=catalog&catalog_code=1-10-$1&%{QUERY_STRING} [L]
RewriteRule^contents/en-us/animal_fancy_dress_costumes\.html$index.php?p=catalog&catalog_code=1-10-1&%{QUERY_STRING} [L]
RewriteRule^contents/en-us/animal_fancy_dress_costumes-([0-9]*)\.html$index.php?p=catalog&catalog_code=1-10-$1&%{QUERY_STRING} [L]

RewriteRule^contents/en-us/Christmas-Costumes-Christmas-Dress\.html$index.php?p=catalog&catalog_code=1-13-1&%{QUERY_STRING} [L]
RewriteRule^contents/en-us/Christmas-Costumes-Christmas-Dress-([0-9]*)\.html$index.php?p=catalog&catalog_code=1-13-$1&%{QUERY_STRING} [L]
RewriteRule^contents/en-us/Christmas_Costumes_Christmas_Dress\.html$index.php?p=catalog&catalog_code=1-13-1&%{QUERY_STRING} [L]
RewriteRule^contents/en-us/Christmas_Costumes_Christmas_Dress-([0-9]*)\.html$index.php?p=catalog&catalog_code=1-13-$1&%{QUERY_STRING} [L]

g1smd

9:17 am on Jul 12, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If the friendly URLs had been designed to include the stock code somewhere within, as well as the longer words, you could do the whole thing in one or two lines of code for the whole site.

lammert

9:26 am on Jul 12, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If you have access to the httpd.conf file, it can be an option to move the rewrite rules which won't change to that file instead. Rules in the httpd.conf file are read and parsed only once when Apache starts, while the .htaccess file is read and parsed with every page request.

jdMorgan

1:17 am on Jul 13, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Another thing you can do is to precede this mess with a "skip rule" such as:

RewriteRule !\.html$ - [L]

which will immediately terminate this pass of mod_rewrite processing if the requested URL does not end with ".html". This prevents the majority of requests (image requests on most sites) from being tested repeatedly against rules which only affect ".html" URLs, and should speed up page loading noticeably.

This will work as long as you have no other rules *following* the cart-generated rules which are intended to rewrite other non-.html URL requests. If so, consider moving them above the cart-generated rules and the skip rule.

Jim

RP_Joe

4:20 am on Jul 26, 2010 (gmt 0)

10+ Year Member Top Contributors Of The Month



Thank you all who have replied. I have been reading and applying your suggestions. I also dug deep into the Apache docs to find all the syntax on rewrite. Very interesting. The page speed has increased.