Cara mempercepat website wordpress tanpa plugin
  • Cara mempercepat website wordpress tanpa plugin

Cara mempercepat website wordpress tanpa plugin - kecepatan akses sebuah website menjadi faktor yang sangat penting sebab jika akses website lambat maka pengunjung website anda meninggalkan website anda

berikut ini adalah Cara mempercepat website wordpress tanpa plugin yaitu dengan membuat cache berupa halaman html ,sehingga pengunjung website anda tidak perlu menunggu waktu lama

Langkah Cara mempercepat website wordpress tanpa plugin
1.Buka/Edit File index.php wordpress anda
 

define('WP_USE_THEMES', true);

 

/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wp-blog-header.php' );

Menjadi

 

<?php

$cache_ext  = '.html'; //file extension
$cache_time     = (3600);  //Cache file expires afere these seconds (1 hour = 3600 sec)

$cache_folder   = '/var/www/html/sastimes/cache/'.date("m").'/'; //folder to store Cache files
$ignore_pages   = array('wp-admin', 'wp-content');
if (!is_dir($cache_folder)) { //create a new folder if we need to
    mkdir($cache_folder);
}
$dynamic_url    = 'http://'.$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . $_SERVER['QUERY_STRING']; // requested dynamic page (full url)

$cache_file     = $cache_folder.md5($dynamic_url).$cache_ext; // construct a cache file
$ignore = (in_array($dynamic_url,$ignore_pages))?true:false; //check if url is in ignore list

if (!$ignore && file_exists($cache_file) && time() - $cache_time < filemtime($cache_file)) { //check Cache exist and it's not expired.
    ob_start(); //Turn on output buffering, "ob_gzhandler" for the compressed page with gzip.
    readfile($cache_file); //read Cache file
    echo '<!-- cached page - '.date('l jS of F Y h:i:s A', filemtime($cache_file)).', Page : '.$dynamic_url.' -->';
    ob_end_flush(); //Flush and turn off output buffering
    exit(); //no need to proceed further, exit the flow.
}
   @ob_start();
######## Your Website Content Starts Below #########
/**
 * Front to the WordPress application. This file doesn't do anything, but loads
 * wp-blog-header.php which does and tells WordPress to load the theme.
 *
 * @package WordPress
 */

/**
 * Tells WordPress to load the WordPress theme and output it.
 *
 * @var bool
 */
define('WP_USE_THEMES', true);

/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
$cache_ext  = '.html'; //file extension
$cache_time     = 3600;  //Cache file expires afere these seconds (1 hour = 3600 sec)
$cache_folder   = '/var/www/html/sastimes/cache/'.date("m").'/'; //folder to store Cache files
$ignore_pages   = array('wp-admin', 'wp-content');

$dynamic_url    = 'http://'.$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . $_SERVER['QUERY_STRING']; // requested dynamic page (full url)

$cache_file     = $cache_folder.md5($dynamic_url).$cache_ext; // construct a cache file
$ignore = (in_array($dynamic_url,$ignore_pages))?true:false; //check if url is in ignore list
if (!is_dir($cache_folder)) { //create a new folder if we need to
    mkdir($cache_folder);
}
if(!$ignore){

    $fp = fopen($cache_file, 'w');  //open file for writing
    fwrite($fp, ob_get_contents()); //write contents of the output buffer in Cache file
    fclose($fp); //Close file pointer
}
ob_end_flush(); //Flush and turn off output buffering

 

Penjelasan

$cache_ext = '.html'; - Format file cache yang akan disimpan

$cache_time = (3600);  - Lama penyimpanan file cache (1 hour = 3600 sec)

$cache_folder = '/account/public_html/'.date("m").'/';    -  Lokasi folder penyimpanan file cache

$ignore_pages = array('wp-admin', 'wp-content'); - halaman yang tidak ingin di cache

Download file Cara mempercepat website wordpress tanpa plugin

Itu adalah tips Cara mempercepat website wordpress tanpa plugin,silahkan di implementasikan pada website anda
 

 

Tags:

Jasa Pembuatan Website
Jasa Pembuatan Website Toko Online
Jasa Pembuatan Toko Online

Our Service