I have OC version 1.5.6.4
What code do I need to add to my .htaccess file for leverage browser caching (1 week)?
Site: http://www.4rissa.com
I am still a beginner at this and help is greatly appreciated

Thanks in advance
Rissa
Code: Select all
# Rabbit Rabbit Security Upgrade, enhanced by Ernie 04/10/2016
Options +SymLinksIfOwnerMatch
# Prevent Directory listing
Options -Indexes
# Prevent Direct Access to files
<FilesMatch "\.(tpl|ini|log)">
Order deny,allow
Deny from all
</FilesMatch>
# disable etags
FileETag none
# SEO URL Settings
RewriteEngine On
RewriteBase /shop/
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
# Enable Gzip Compression
AddOutputFilterByType DEFLATE text/text
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
# Remove Browser Bugs
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
<IfModule mod_deflate.c>
<FilesMatch "\.(js|css)$">
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>
# cache gif, jpg, and png files for one week
<FilesMatch ".(gif|jpg|png)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
# Leverage Browser Caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 week"
ExpiresByType image/jpeg "access plus 1 week"
ExpiresByType image/gif "access plus 1 week"
ExpiresByType image/png "access plus 1 week"
ExpiresByType text/css "access plus 1 week"
ExpiresByType application/pdf "access plus 1 week"
ExpiresByType text/x-javascript "access plus 1 week"
ExpiresByType application/x-shockwave-flash "access plus 1 week"
ExpiresByType image/x-icon "access plus 1 week"
ExpiresDefault "access plus 1 week"
</IfModule>
My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.
Code: Select all
<?php
class Response {
private $headers = array();
private $level = 0;
private $output;
public function addHeader($header) {
$this->headers[] = $header;
}
public function redirect($url, $status = 302) {
header('Location: ' . str_replace(array('&', "\n", "\r"), array('&', '', ''), $url), true, $status);
exit();
}
public function setCompression($level) {
$this->level = $level;
}
public function setOutput($output) {
$this->output = $output;
}
public function getOutput() {
return $this->output;
}
private function compress($data, $level = 0) {
if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) && (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false)) {
$encoding = 'gzip';
}
if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) && (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip') !== false)) {
$encoding = 'x-gzip';
}
if (!isset($encoding) || ($level < -1 || $level > 9)) {
return $data;
}
if (!extension_loaded('zlib') || ini_get('zlib.output_compression')) {
return $data;
}
if (headers_sent()) {
return $data;
}
if (connection_status()) {
return $data;
}
$this->addHeader('Content-Encoding: ' . $encoding);
return gzencode($data, (int)$level);
}
public function output() {
if ($this->output) {
if ($this->level) {
$output = $this->compress(minify($this->output), $this->level);
} else {
$output = minify($this->output);
}
if (!headers_sent()) {
foreach ($this->headers as $header) {
header($header, true);
}
}
echo $output;
}
}
}
function minify($html)
{
$html = preg_replace("`>\s+<`", "> <", $html);
$replace = array(
' ' => ' ',
'©' => '©',
'â' => 'â',
'¢' => '¢',
'»' => '»',
'«' => '«'
);
return $html;
}
?>
My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.
Users browsing this forum: Baidu [Spider] and 16 guests