Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Senior Member medlington's Avatar
    Join Date
    Nov 2005
    Location
    Sheffield, UK
    Posts
    377
    Member #
    11968
    Liked
    4 times
    Hi,

    Im just remaking our company website and im going to run it all on a custom CMS that Ive made so that my web illiterate business partner can update it too.

    The problem that I forsee is that with our hosting account the DB isnt on the same server ie 'localhost' and as such each time I try to access the DB it has to create a connection with another server. This has prooved to be quite unreliable in the past and I've often got a MYSQL cannot connect' error.

    What Im thinking is that when the DB is accessed on the home page it gathers some data about the other pages and stores this data in a session variable so that it doesnt need to make another DB connection later on that may fail.

    As an example, our projects will be stored within a DB and each one either has an image or a piece of flash to display, all I really need to know about this project is if Flash is set to 'No' and if not what it is set to. I doubt we'll ever have more than about 40 projects on the site at once so the initial DB querey wont take that long and I could write all the required info to sessions to be processed later.

    Can anyone see any advantages / dissadvantages of doing it this way?

    Would I be better adding some code to the DB querey that checks if it has been successfull instead?

    Thanks

  2.  

  3. #2
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Instead of storing it in the session, cache it in the filesystem as pre-rendered html pages. Then use the file age to determine if you need to overwrite from the DB, based on how long you want to cache your files for.

  4. #3
    Member
    Join Date
    Jan 2011
    Location
    Edmonton, Alberta
    Posts
    82
    Member #
    26483
    Liked
    2 times
    Session variables are generally effective only for specific user information. I would just query the database for the specific information you require. As maneet said, you have to query the database for session variables anyway, so you might as well just use the database.
    Check out some of my work: http://www.jr-webdesigns.com

  5. #4
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    A couple of weeks back, I ran into a cart that stored most things in session and application variables, which would have made sense for a few different things...except that the cart in question stored over 700 of them, including many session/application variables that were already hard-coded into a config file.

    It took me about 5 hours to untangle that mess and reconfigure the cart so that all the variables were hardcoded with a bit of trickery. The pages that used to take over 5 seconds to load loaded at most in just under half a second.

    My point is...if you must use session/application variables, keep it to a minimum.

    Now, if you're running into intermittent connection failure issues, it's likely not a code issue, but one with your hosting server. There's no reason you should be getting a connection failure for anything, even if the database resides on a different server. I've coded several sites where the database was housed on a dedicated database server and had absolutely no issues that way whatsoever. Heck, that's how my billing app works...I run it from here in Toronto and my database for it isn't even in the country.

    So for your own sake, let your host know about it and copy/paste the error when you get it.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 01:58 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com