Speed up your Website with this Simple Page Cache Script for PHP
For dynamic websites, database queries take up a significant amount of the CPU resources of your servers. For medium to high traffic websites in shared or virtual hosting services, this could mean significant loss of traffic due to too much database queries or over use of shared CPU time. As such, it is quite useful to have some sort of cache system for your dynamic pages, particularly those with content that don’t change too much or too often anyway. Below is a very simple and generic cache script for PHP web pages which you can copy-paste and use almost instantly in your website. What it does is store an instance of the dynamically generated web page as an HTML file and it then counter checks with a predefined time period that you set whether to display the cached instance or to dynamically generate the page again. The longer the time period between dynamic generation, the greater the savings in terms of CPU usage and database queries. 1. First create a folder in your hosting account where you’ll be housing the cached data. In this example the cache folder is located at http://www.yourdomain.com/cache 2. Next, copy-paste the script below at the start of the PHP page you want cached. We are assuming here that the dynamically generated page is utilizing the GET variable “id”, such as: http://www.yourdomain.com/index.php?id=XXXX: 3. At the bottom of your PHP page, copy-paste the code below: 4. You’re done! Upload and update your PHP file.
Setting Up Google Adsense for Domains in Dreamhost
For those of you who have idle domains parked/hosted with Dreamhost, below is a short walk-through on how to use Google’s Adsense for Domains on your Dreamhost domain(s). Go to Domains -> Manage Domains and locate the domain you want to use Adsense for Domains on. On the Web Hosting Column (the 3rd from left)..click on DELETE for the selected domain. If you don’t do this, the DNS settings for the domain will be “locked” by Dreamhost and you’ll get an error saying that your entries are invalid or have a duplicate. Â Next, click on DNS on the first column under the domain name of you site. If you did the first step correctly there shouldn’t be a lot of entries left for “Non-editable DreamHost DNS records for yourdomain.com” section. Make sure the Nameservers are pointing to Dreamhost (ns1.dreamhost.com, ns2.dreamhost.com, ns3.dreamhost.com). Next, on the custom DNS section, type”www” for the name, then select “CNAME” for the type and for the “value” put in pub-xxxxxxxxx.afd.ghs.google.com. where pub-xxxxxxxxx is your unique Adsense for Domains ID. (you’ll find this on the Adsense Setup-Adsense for Domains in google.com/adsense). Once done with that it’s time to put in four (4) A records pointing to the following IP Addresses with the “name field” left as BLANK (as oppose to the walkthrough here: https://www.google.com/adsense/support/bin/answer.py?answer=76049 which says you need to put an “@” value: Host Name/Alias Record Type Value/Destination <LEAVE BLANK!> A (address) 216.239.32.21 <LEAVE BLANK!> A (address) 216.239.34.21 <LEAVE BLANK!> A (address) 216.239.36.21 <LEAVE BLANK!> A (address) 216.239.38.21 After step 5 go back to your Google Adsense account and click “Request Ownership Verification” on the Actions drop-down. That’s about it! Just wait a few hours and your site should be verified and ready for customization via Google Adsense.
WAMP Installation Guide
WAMP Installation Guide WAMP (Windows-Apache-mySQL-PHP) is an all-in-one packages which installs the basic programs you will need to get a localhost running and to be able to build and run PHP scripts. This guide will walk you through installing a WAMP package for the first time. Step 01: Open WAMP website. Step 02: Open the DOWNLOADS page. Step 03: Choose version to install. *note: Ask supervisor which version to use. Step 04: Installing older version. Step 05: Installing older version: Re-direction to download page. Step 06: Installing older version: Checking which WAMP version to use. Step 07: Choosing download mirror and downloading. Step 08: Run the installer file. Step 09: Run the installer file: License Agreement. Step 10: Run the installer file: Saving Directory Step 11: Run the installer file: Creating Start Menu Folder Step 12: Run the installer file: Auto-launch WAMP on Startup Step 13: Run the installer file: Confirmation of Installation Settings Step 14: Run the installer file: Saving Document Root Folder Step 15: Run the installer file: Default Browser and Finishing the Installation Step 16: Manually Starting WAMP Server Step 17: Testing the LOCALHOST NOTE Step 01: Open the WAMP website at http://www.wampserver.com/en/index.php. You should be able to see a page like this: [Back to Top] Step 02: Click the DOWNLOADS link. [Back to Top] Step 03: Ask your OJT supervisor which versions of mySQL and PHP would you be using. If it is ok to use the newest available version of WAMP then click the DOWNLOAD link to install. Proceed to Step 07 if you would do this step. [Back to Top] Step 04: If you would require a version of WAMP with older version/s of either Php, mySQL, or phpmyAdmin click on the PREVIOUS VERSIONS link. [Back to Top] Step 05: You will be directed to the download page of all the older versions of WAMP, such as below. Scroll down and click the VIEW OLDER RELEASES link. [Back to Top] Step 06: You will then be directed to a page such as below. To check which version of WAMP has the versions of the programs you need, scroll down and click on any of the NOTES links in the page, as illustrated below. It will direct you to a page such as below. Scroll down to search for the appropriate version that suits your requirements. Return to the previous page after taking note of what version you will use, then select the version you would need to use. [Back to Top] Step 07: Whether or not you would need to download the newest version of WAMP, you would be directed to a page where you would select mirrors for the download. You could choose any mirror you would like but personally I would advice choosing either Japan or Taiwan as a mirror, or any Asian country for that matter (they?re closer to the Philippines). You should be able to see a page like this: After choosing a mirror, save the file to your computer. [Back to Top] Step 08: Once download finishes, run the installer file. [Back to Top] Step 09: In the license agreement click [I accept the agreement], then click next. [Back to Top] Step 10: Select the directory where you would like to install WAMP. [Back to Top] Step 11: Select the start menu folder where you would like to place WAMP?s shortcuts. [Back to Top] Step 12: In the additional tasks you may select if WAMP would be loaded on startup or no. If its most likely that you would be programming PHP as soon as you start your computer (most likely yes) then I suggest you select the checkbox. Otherwise you may opt to leave it unchecked and turn on the WAMP server manually. [Back to Top] Step 13: This is the confirmation screen of the options you have selected. Click back to modify your install settings or click next to start the installation. [Back to Top] Step 14: Some time midway into the installation a window will pop-up asking for the directory where to save the document root folder. It is recommended that you leave it as it is and click ok to continue the installation. [Back to Top] Step 15: After the said pop-up another window will appear asking for you default browser. If you have no preference for browsers just hit Open. If not search for the .exe file of your preferred browser then click Open to continue the installation. Once the installation is finished, click finish. [Back to Top] Step 16: To manually start the WAMP server, click Start>Programs>WampServer or [name you assigned in Step 15] >start WampServer. This is illustrated below: [Back to Top] Step 17: Open your preferred browser and type in the address bar LOCALHOST. It should display the WAMP homepage like below, signifying a successful installation. Click this link to try launching the localhost > http://localhost [Back to Top] NOTE: Always remember to enable the WAMP server (if it isn’t already enabled) as illustrated in Step 16 whenever you want to test any page in the localhost. [Back to Top]