Website pages very slow to load on first access

Since you don't provide this information I will assume you are using mysql. There are many things to check, but you can start with :

  1. Download and execute this perl script. Read and understand the suggestions it outputs, it will help optimize your db.
  2. Find slow db queries. Unoptimized db queries can take much time to execute the first time and then are recovered from the cache, thus the difference. Check the slow query log and look for max execution time.
  3. Another one is name resolution on the db side, are you doing name resolution on db connect (check this to make sure) ?