Free Digital World
  • Categories
  • Features
    • Content Blocks
    • Content Formatting
    • Contact Form
  • Buy Now

Categories

  • Digital Business
  • Digital Marketing
  • Ecommerce
  • Free Courses
  • Social Media Marketing
  • Webmaster
  • Wordpress
Free Digital World
  • Categories
  • Features
    • Content Blocks
    • Content Formatting
    • Contact Form
  • Buy Now
Subscribe
WWordpress

How Can I Compress And Cache For Godaddy Shared Hosting WordPress

I got a better solution from a website called

http://wordpresspartner.com/tutorials/godaddy-htaccess-gzip/

The solution:

This solution is tested by only wordpress as per the owner.

This solution to speeding up your Godaddy hosted Website has 4 actions:

  1. Create a PHP file to compress CSS
  2. Create a PHP file to compress JavaScript
  3. Save the two new PHP files to the root of your Website
  4. Add entries to your Website .htaccess file to run the two compression scripts and cache images (including ico images).

Here are more detailed instructions:

1. Create a PHP file to compress CSS

Create a file called compress-css.php (this is likely best created in a text editor such as Notepad or Notepad++) and save it on your local computer. Copy and paste the following into compress-css.php:

<?
ob_start("ob_gzhandler");
header("content-type: text/css; charset: UTF-8");
header ("expires: " . gmdate ("D, d M Y H:i:s", time() + 302400) . " GMT");
header("Cache-Control: max-age=302400, public, must-revalidate", true);
echo "/*n";
echo "Generated by www.wordpresspartner.comn";
echo "*/n";
echo file_get_contents($_GET['file']);
?>

2. Create a PHP file to compress JavaScript

Create a file called compress-js.php (this is likely best created in a text editor such as Notepad or Notepad++) and save it on your local computer. Copy and paste the following into compress-js.php:

<?
ob_start(“ob_gzhandler”);
header(“content-type: text/javascript; charset: UTF-8″);
header (“expires: ” . gmdate (“D, d M Y H:i:s”, time() + 302400) . ” GMT”);
header(“Cache-Control: max-age=302400, private, must-revalidate”, true);
echo “/*n”;
echo “Generated by www.wordpresspartner.comn”;
echo “*/n”;
echo file_get_contents($_GET['file']);
?>

3. Save the two new PHP files to the root of your Website

Copy compress-css.php and compress-js.php to the root of your Website (this is usually achieved via FTP).

4. Add entries to your Website .htaccess file to run the two compression scripts and cache images

Add the following to the end of the .htaccess file (usually at the root of your Website). If a file named .htaccess doesn’t exist then create a file named .htaccess in a text editor, add the text below and then transfer to the root of your Site.

# BEGIN Compression and Caching Script per http://wordpresspartner.com
# This calls the ‘compress-css.php’ and ‘compress-js.php’ files
<ifModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*.(css))$ compress-css.php?file=$1
RewriteRule ^(.*.(js))$ compress-js.php?file=$1
</ifModule>
# This enables caching
<ifModule mod_headers.c>
<filesMatch “\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$”>
Header set Cache-Control “max-age=2592000, public”
</filesMatch>
<filesMatch “\.(xml|txt)$”>
Header set Cache-Control “max-age=216000, public, must-revalidate”
</filesMatch>
<filesMatch “\.(html|htm|php)$”>
Header set Cache-Control “max-age=1, private, must-revalidate”
</filesMatch>
</ifModule>
# End Compression Script

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You May Also Like
WWordpress

How To Include Recent Latest WordPress Posts In My Site Home Page

Here you can easily insert / include / embed the recent or latest 3 or 5 or 10…
WWordpress

Robots Txt File For WordPress Blog

Many people are asking what is the best and common robots.txt file for a wordpress site/blog? So here…
WWordpress

Htaccess 301 Redirect Apache Server

While there are many ways in implementing 301 redirect code in your .htaccess page, here I am putting…
Free Digital World
Designed & Developed by Code Supply Co.