Jump to content
Shaman Daniels

[Модификация] Ускоряем роботу сайта

Recommended Posts

1. В .htaccess добавить:

FileETag MTime Size
<ifmodule mod_expires.c>
<filesmatch ".(jpg|jpeg|gif|png|ico|css|js)$">
ExpiresActive on
ExpiresDefault "access plus 1 month"
</filesmatch>
</ifmodule>
<ifModule mod_gzip.c>
  mod_gzip_on Yes
  mod_gzip_dechunk Yes
  mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
  mod_gzip_item_include handler ^cgi-script$
  mod_gzip_item_include mime ^text/.*
  mod_gzip_item_include mime ^application/x-javascript.*
  mod_gzip_item_exclude mime ^image/.*
  mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
<ifModule mod_expires.c>
  ExpiresActive On
  ExpiresDefault "access plus 1 seconds"
  ExpiresByType text/html "access plus 1 seconds"
  ExpiresByType image/gif "access plus 2592000 seconds"
  ExpiresByType image/jpeg "access plus 2592000 seconds"
  ExpiresByType image/png "access plus 2592000 seconds"
  ExpiresByType text/css "access plus 604800 seconds"
  ExpiresByType text/javascript "access plus 216000 seconds"
  ExpiresByType application/x-javascript "access plus 216000 seconds"
</ifModule>
<ifModule mod_headers.c>
  <filesMatch "\\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$">
    Header set Cache-Control "max-age=2592000, public"
  </filesMatch>
  <filesMatch "\\.(css)$">
    Header set Cache-Control "max-age=604800, public"
  </filesMatch>
  <filesMatch "\\.(js)$">
    Header set Cache-Control "max-age=216000, private"
  </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>

2. Работем в файлах index.php и templates.php
2.1 Заружаем accelerator.php в /system/classes/
2.2 Открить index.php

Перед:

define('ENGINE_DIR', ROOT_DIR.'/system');

Добавить:

include('/system/classes/accelerator.php');

2.3 Открить templates.php
После:

function load_template($tpl_name) {

Добавить:

if( $this->CacheTemplate[ $tpl_name ] )
    {
        $this->copy_template = $this->CacheTemplate[ $tpl_name ];
        return true;
    }

После:

$this->copy_template = $this->template;

Добавить:

$this->CacheTemplate[ $tpl_name ] = $this->template;

PS: Работает или нет - не понятно.

 

accelerator.php

Share this post


Link to post
Share on other sites

include('/system/classes/accelerator.php');

так пути лучше не прописывать пишите так include(ENGINE_DIR.'/classes/accelerator.php');

а почему так не стоить прописывать ?

Share this post


Link to post
Share on other sites

include('/system/classes/accelerator.php');

так пути лучше не прописывать пишите так include(ENGINE_DIR.'/classes/accelerator.php');

уже понял

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×