0
Welcome Guest! Login
0 items Join Now

How to Add Server Side Compression Updated

    • Aurora's Avatar
    • Aurora
    • Elite Rocketeer
    • Posts: 903
    • Thanks: 0

    How to Add Server Side Compression Updated

    Posted 16 years 5 months ago
    • System: Joomla 1.5.8
      Template: Hyperion J1.5 ::: RT Package

      Discussion: here ill walk through how to add server side compression in the RT templates hope this can be implemented some time in the future for some of the templates especially when you have to deal with flash and faster site load.

      in your index.php file put this function in i have it right under the other ones thats already there,
      $compress = $this->params->get("compress", "1"); // 1 = TURN COMPRESSION ON | 0 = TURN COMPRESSION OFF


      in this file templatedetails.xml has this
      <param name="compress" type="radio" default="1" label="Server Side Compression" description="Activate Server Side Compression for faster site load">
      <option value="1">Enable</option>
      <option value="0">Disable</option>
      </param>

      rt_head_includes.php has this
      <?php

      // CSS JS Server Side Compression
      if ($compress == 1){
      $jsextens ='php';
      $cssextens ='php';
      }else{
      $jsextens ='js';
      $cssextens ='css';
      }

      ?>

      first and formost go into your css direcotry and changed your template_css.css to template_css.php and if you want the other css files to be compressed also do the same with them, and changed them to end with the .php extension. so you should have both css files and php files in there. as you can see below if your like me and like to have files separate on your server for better management thats fine also, below you can see i have those files in my css directory and an separate temp_css.css file and used the css @import function to have files load on the fly as if there in one file. and just link to it only one file, in my rt_includes_header.php or something if thats the file on your server that loads all the header info. i don't like to load alot of css files so i used before below or just have them in one file.

      @import url("banners.php"); /*banners css file*/
      @import url("bookshelf.php"); /*banners css file*/
      @import url("rokmininews.php"); /*rokmininews css file*/
      @import url("rokmininews-more.php"); /*rokmininews-more css file*/
      @import url("style1.php"); /*stle1 css file*/

      in all your files that ends with the .php extension add this fuction at the very top of that file. please do this for all the extesion thats in your css directory or js file to have this in the header.what it does is it caches it then expire then in an hour

      <?php
      ob_start ("ob_gzhandler");
      header("Content-type: text/css; charset: UTF-8");
      header("Cache-Control: must-revalidate");
      $offset = 60 * 60 ;
      $ExpStr = "Expires: " .
      gmdate("D, d M Y H:i:s",
      time() + $offset) . " GMT";
      header($ExpStr);
      ?>

      @import url("banners.php"); /*banners css file*/
      @import url("bookshelf.php"); /*banners css file*/
      @import url("rokmininews.php"); /*rokmininews css file*/
      @import url("rokmininews-more.php"); /*rokmininews-more css file*/
      @import url("style1.php"); /*stle1 css file*/

      this below uess the cssextens function to compress all the .php extesions in that css directory if you have the mod_gzip or mod_deflate enabled on your server.
      <link href="<?php echo $this->baseurl; ?>/templates/<?php echo $this->template?>/css/template_css.<?php echo $cssextens; ?>" rel="stylesheet" type="text/css" />

      <link href="<?php echo $this->baseurl; ?>templates/<?php echo $this->template?>/css/<?php echo $css_file; ?>.<?php echo $cssextens; ?>" rel="stylesheet" type="text/css" />

      and if your following this tutorial from top down youll add the other info that is at the top in the files needed, i havn't setup the part for js yet, but its all the same way i did with css ill do with js, any chages ill post back here, if any one fine this useful an can modify it to work better plz share here, cause am still working on the code, and getting it to work with all templates.

      NOTE: when i first test an default hyperion installation with yslow i got an (F), when i enabled this method i went from an (F) to an (A), there is something i miss though i believe cause after testing and testing i went back from an (A) to an (F), i was reading on some forum that can be server issue, but who knows, am just trying to speed up all rt templates for faster loading, anyone again fine this info useful and modify it to work better plz post again here so i can see what i have missed or what else could be done. am still testing it and more testing. hope this method can be improved and implemented in RT family templates

      heres is my other link i had posted in the hyperion section about Automatic merging and versioning of CSS/JS files with PHP which is another method am using to speed up RT templates.
      www.rockettheme.com/forum/index.php?t=47505&rb_v=viewtopic

      and here again the link to the original post in hyperion section about adding server side compression
      www.rockettheme.com/forum/index.php?t=47519&rb_v=viewtopic
    • Last Edit: 16 years 5 months ago by Aurora.
  • Re: How to Add Server Side Compression Updated

    Posted 16 years 5 months ago
    • If I want to compress and I know the server supports mod_deflate, Wouldn't it be easier to just add

      AddOutputFilterByType DEFLATE text/html text/xml text/javascript text/css application/x-javascript application/javascript

      in the .htaccess?
    • Last Edit: 16 years 5 months ago by Sonny Menajang.
    • Aurora's Avatar
    • Aurora
    • Elite Rocketeer
    • Posts: 903
    • Thanks: 0

    Re: How to Add Server Side Compression Updated

    Posted 16 years 5 months ago
    • Sonny Menajang wrote:
      If I want to compress and I know the server supports mod_deflate, Wouldn't it be easier to just add

      AddOutputFilterByType DEFLATE text/html text/xml text/javascript text/css application/x-javascript application/javascript

      in the .htaccess?

      ya your right but am talking about adding it in the template it self, to serve css and js files, faster, on compression, already some joomla website have this implemented in there website, so am just trying to help out RT Family, see if its an gud solution, i have in the past tried that function you posted didn't do much i have to move the .htacess to the css,js and or imgs directory, am only working on a different approach on compressing RT templates css,js,images, and components,etc for faster site load. anyone want to see my advance .htaccess file you can dl it here

      xtrahype.webs.com/misc/htaccess1.txt

      i was testing joomla 1.5.8 system plugin cache feature and it works like a charm also, site loads fast but still got an (F) in yslow, i got an (A) before but didn't document what i did, so am trying all solutions on having templates load faster. thanks for you guys insight and your ideas are greatly appreciated.
    • Andy Miller's Avatar
    • Andy Miller
    • Preeminent Rocketeer
    • Posts: 9919
    • Thanks: 96
    • Web Kahuna

    Re: How to Add Server Side Compression Updated

    Posted 16 years 5 months ago
    • Thanks for this info. We will investigate implementing this kind of technique in our future templates.
    • Aurora's Avatar
    • Aurora
    • Elite Rocketeer
    • Posts: 903
    • Thanks: 0

    Re: How to Add Server Side Compression Updated

    Posted 16 years 5 months ago
    • Andy Miller wrote:
      Thanks for this info. We will investigate implementing this kind of technique in our future templates.

      your welcome, thanks andy for looking to newer approaches, as am still working on this method and getting css an js also images files compress on all types of servers using RT templates. ill post back if i have any lead, anyone have any ideas on this or input we can work on it together let me know your input also. thanks everyone for yur info and time.

      also andy if we can lower the amount of css loaded and js files, is also an factor, we should be looking at using CSS sprites convention and such in making css functions look more cleaner, that plays a big role also in gettin css files smaller, am still learning this new technique and implementing it in my RT templates for testing also. who knows maybe next year RT templates will have this newer technique and faster templates well see what happen until then and thanks again guys
    • Last Edit: 16 years 5 months ago by Yves.

Time to create page: 0.063 seconds