Page 1 of 1

Serve static content from a cookieless domain

Posted: Thu Jan 12, 2017 9:37 pm
by 13pixels
Hey Guys,

I have tested my website on and overall I got a nice score. But I keep running into a "F" grade on serve static content from a cookieless domain. I have seen a couple of websites on how to solve this and even some topics here. But none had the perfect solution. Does anybody know how to solve this?

I run OC and Journal 2 theme.

Looking forward to the reply's

Re: Serve static content from a cookieless domain

Posted: Thu Jan 12, 2017 9:45 pm
sarch in the Extension Section for this: ... n_id=23506

Re: Serve static content from a cookieless domain

Posted: Thu Jan 12, 2017 10:08 pm
by 13pixels
Thanks! I see you have made this? Would you give any support on this?

Re: Serve static content from a cookieless domain

Posted: Fri Jan 13, 2017 2:59 am
Well, one does not really need support, everything is descrided, and it usually works,
independent of the Theme used. But I don't know about the Journal Theme, because
Journal is not just a Theme, by the Volume of Code it add's to a Shop Site! :D
So, I could NOT be of help anyway, but let me try once more again to get BASIC:
1. In your CONFIG.PHP Files, you PROBABLY have the Site URL configured as:
http : //www. (or: http: //www.
and therefore, your OC-default IMAGES are linked like:
http : //www. (or: http: //www.
2. To MAKE image-links cookiefree, your IMAGE links must only! be called as:
http : //, not http : //www.,
because, for a Browser, this is another Site, as http:// without a www.
Alias-Name added to .;)
3. IF the REVERSE Case applies, everything is done the opposite Way,
and images are to be linked trough www.!
Take this sample (admin) technically simple second-domain-image
config.php file content:
(the ROOT config.php would be linked similarly, just without the admin Lines!)

Code: Select all

define('HTTP_SERVER', '');
define('HTTP_CATALOG', '');
define('HTTP_IMAGE', '');
define('HTTPS_SERVER', '');
define('HTTPS_CATALOG', '');
define('HTTPS_IMAGE', '');
And now, we use a VqMod, to tell the OC Software, that, in the:
catalog/model/tool/image.php File,
(possibly moved elsewhere in later OC-2 Versions!)
it's both default OC Code Linking Routines, looking like:
return $this->config->get('config_ssl') . 'image/' . $new_image;
return $this->config->get('config_url') . 'image/' . $new_image;

are not longer used, as default Source- 'internal' GET-Routine, but replaced
by a config.php defined IMAGE HTTP Link, and the VqMod,
thereby changing (among another line, in other xxx.php Files) those Lines:
return $this->config->get('config_ssl') . 'image/' . $new_image;
return HTTPS_IMAGE . $new_image;
return $this->config->get('config_url') . 'image/' . $new_image;
return HTTP_IMAGE . $new_image;
in the catalog/model/tool/image.php . And depending on, if it's a secure HTTPS
Site Call or a regular HTTP Call. And if the VqMod is switched OFF, everything works
as by DEFAULT again, exept for possibly manually rewritten image Links, like a Logo !
And this, combined with the added config.php Image Link Lines, makes your
Shop Images (largely) cookiefree. Exept for the Shop Logo, and a few other
oc-hardcoded linked images, wich I changed manually later, to look like, i.E., in the
... theme ... / template/common/header.tpl File:

Code: Select all

<a href="<?php echo $home; ?>"><img width="268" height="50" src="" title="<?php echo $name; ?>" alt="<?php echo $name; ?>" class="img-responsive" /></a>
And to have most of your Stylesheets and Scripts also working cookiefree,
check on the image linked below, to see, how I linked MOST such in the header.tpl File,
in the HTTP way. ;)
Just be careful with the USE of that ASYNC Delay-JS-command, it may
hinder most important Scripts from executing in order, if a Page is not reloaded first.
And this makes no sense, technically, regardless of, what ANY Site Test Tools
mean to this... ;)
And get all of your .CSS and .JS Stuff compressed, either by Google Pagespeed or GTMETRIX, by testing all possible Sections+Functions of your Shop, to get' em all
compressed! Or then, do it on a Site like here:
And just be aware, FONTAWESOME and (possibly) BOOTSTRAP-related header
linking is NOT possible this way, leave them, as they are written, in the header.tpl, like:

Code: Select all

<link rel="stylesheet" type="text/css" href="catalog/view/fontawesome/css/font-awesome.min.css" media="screen, projection" />
<link rel="stylesheet" type="text/css" href="catalog/view/theme/<?php echo $this->config->get('config_template');?>/bootstrap/css/bootstrap.css" media="screen, projection" />
Or then, get at the FontAwesome/Bootstrap Code from a place like this, to have it
cookiefree too. It will NOT make the pageload any faster, the contrary may be the case,
but it at least displays it's OC-2 related ICON's, possibly used in your Theme too,
regardless of, how a Site URL is called! Wich is NOT the Case, at least with FontAwesome.

Code: Select all

<link href="//" rel="stylesheet">
And to round it up, in the latest Test VqMod, linked below, the ever
OC-missing Image WIDTH + HEIGHT Tags are also added, if you use
this VqMod, then, GTMETRIX will really like you ! :D

My latest Test VqMod Version includes an ADMIN Image Link Section,
but it works only with selected IMAGE MANAGERS. If it does NOT longer display
Images in your Image Manager, or anywhere else, remove the entire ADMIN
Section from the VqMod! Should work anywhere, exept for possibly OC v.2.3.x.
And check on my favoured .htaccess File, it could make a difference too ... :D ... ation_id=4
That's all, good Luck ! :D
PS: And you may need something like this, to be inserted into your:
.htaccess file,
to make sure, all 'incorrect' Site Calls are 'redirected' to the correct URL!
It's now coded to switch HTTP://site to HTTP://

Code: Select all

# SEO URL Settings
RewriteEngine On
RewriteBase / ###  or your Shop-dir-Name, like RewriteBase /shop/  ###

#Force (http host) www to non www (optional)
#RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
#RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

#Force (https host) www to non www (optional)
#RewriteCond %{HTTPS} on
#RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
#RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

#Force (http host) non www to www (optional)
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

#Force (https host) non www to www (optional)
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
:crazy: END :crazy: never again...

Re: Serve static content from a cookieless domain

Posted: Sun Jan 15, 2017 8:49 pm
by villagedefrance
A very good and useful answer.

Great job Ernie!