27
(copied from my own blog at https://www.gui.do/post/101-ways-to-speed-up-your-magento-e-commerce-website)
A) Hosting environment/ General tips
Get a dedicated server.
Host your site in the country where your customers are.
Don't host files on your web server that you do not use, large or small.
Goto MySQL Admin and select all the tables and ...
8
This is how I've done it right now.
Overriding CMS template filter
The CMS Helper contains two methods called getPageTemplateProcessor() and getBlockTemplateProcessor() which will do Mage::getModel(...) with input of the configured model name from the config respectively at global/cms/page/tempate_filter and global/cms/block/tempate_filter.
So add this to ...
6
There is no difference. The default offloader header in Magento 2 is X-Forwarded-Proto, which matches the de facto standard.
SSL_OFFLOADED on the other hand, was the default offloader header in Magento 1, and also used by Nexcess_Turpentine, the popular Varnish extension for Magento 1.
Basically, you can call the header however you want, you just have to ...
answered Dec 22 '16 at 10:33
Fabian Schmengler
63.2k2323 gold badges169169 silver badges394394 bronze badges
6
So I spent sometime working through this. It appears you can't
Header set
inside of a FilesMatch
I fixed the issue using the following inside of my pub/static/.htaccess
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "https://url-to-my-cdn-instance"
<FilesMatch .*\.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|...
5
In Observer method
$response = $observer->getEvent()->getData('response');
if (!$response)
return;
$html = $response->getBody();
if ($html == '')
return;
$conditionalJsPattern = '@(?:<script type="text/javascript"|<script)(*)</script>@msU';
preg_match_all($...
4
As you mentioned that you should use $j because of the noConflict() I'm pretty you can fix your issue by replacing:
jQuery.noConflict();
With:
$j = jQuery.noConflict();
Edit: the problem was that the OP forgot to use $j(document).ready in its main js code.
answered Sep 5 '16 at 14:40
Raphael at Digital Pianism
66.7k2929 gold badges168168 silver badges336336 bronze badges
4
This depends slightly which Speedster extension you are using. If you are using the original Speedster this does not support a CDN set up and never will.
For Speedster Advanced the extension will follow your settings for media,skin and js. If you are using a CDN which pulls from the origin a configuration like this will work:
The files are created on your ...
4
Images - I have seen many cases where the person uploading images (products, CMS pages, etc) is not trained in how to optimize image sizes. There are plenty of articles available online, but a lot of it is just common sense.
Don't use images for text.
Use JPEG/GIF/PNG appropriately (ie. generally don't use PNG for photographic images)
Use sprites for small ...
4
You can find code in below url, how you can define your custom directives to use in Magento CMS pages & Static Block.
http://dltr.org/blog/magento/567/Magento-add-your-own-CMS-Directive-to-include-your-custom-template-tag
I have used this method before for me & its worked well for me.
4
You can tell Magento to use static files and media files from a CDN from the admin dashboard. Go to Stores > Configuration. Under the Web tab you can link the CDN in Base URL for Static View Files and Base URL for User Media Files. Don't forget to flush the cache after you change the settings.
3
If you want a ready-to-go solution I would go with the OnePica module that offers several integrations with CDNs from different vendors.
"Currently, the extension integrates with Amazon S3, Coral CDN, Mosso/Rackspace Cloud Files, and any CDN, server or service that supports FTP, FTPS, or SFTP. "
http://www.magentocommerce.com/magento-connect/onepica-...
answered Feb 18 '15 at 7:43
3
There is more to it than just caching such as image, session and browser optimisation. See more here - https://www.cloudflare.com/features-optimizer/
3
It was a problem of my hosting service: Hostgator, the integrated panel function doesn't work, you have to follow the manual instruction on cloudflare and disable the function of cpanel
3
Here is a module that allows you to use cloud flare with magento:
it's called: Control for CloudFlare
http://www.magentocommerce.com/magento-connect/control-for-cloudflarer.html
Here is a module for CDN, its called: OnePica ImageCDN
http://www.magentocommerce.com/magento-connect/onepica-imagecdn-1.html
3
Because your image-urls are hardcoded in css:
To fix this problem, do the following:
disable css-merging from backend (System -> Configuration -> ADVANCED -> Developer then CSS Settings and set Merge CSS Files to No)
reload your frontend and view your page with developer tools (i.e. F12 in Google Chrome) and find the images mentioned in GTMetrix. (Probably ...
2
Images are a huge problem on the internet, almost as big of a problem as javascript. The first thing that you need to do is optimize your images.
Setup a Content Delivery Network
Optimize your images
Use an Image LazyLoader
Now onto your Javascript files:
Compress and combine them
Eliminate additional page reloads by using more ajax
Drop your JS files ...
2
Try the event catalog_product_gallery_upload_image_after this should be fired on the upload action of the controller Mage_Adminhtml_Catalog_Product_GalleryController from your question I think this is the right event for you.
answered Jan 23 '15 at 17:33
David Manners
26.8k99 gold badges6868 silver badges218218 bronze badges
2
This is extremely simple to achieve and there is absolutely value in making this change despite not using a formal CDN.
CDN's don't always improve performance for your domestic market (in some cases it will make it slower). You'll lose nothing setting up a few sub domains, and potentially gain a little.
The real advantage to using sub domains for static ...
2
After some research on how to override a function on a Model, I've created my own module/extension. This extension extends the Mage_Catalog_Model_Product_Image Model and this is what I've changed to make it work:
class ImageCdn_Model_Catalog_Product_Image extends Mage_Catalog_Model_Product_Image
{
protected $_cdnFile;
public function setBaseFile($...
2
To add external static resources like CSS, JavaScript, Web fonts (Fontawesome in this case), Please follow the steps below.
Go to this link and copy the CDN URL of Fontawesome.
Find the file app/design/frontend/{Themevendor}/{Themename}/Magento_Theme/layout/default_head_blocks.xml and paste the line below. (The line should be placed in the head tag and the ...
2
Offloader header and HTTPS server variable are used by Magento 2 to figure out if request is secure (https).
if you don't set server variable HTTPS
fastcgi_param HTTPS on
then magento checks Offloader header:
vendor/magento/framework/App/Request/Http.php
public function isSecure()
{
if ($this->immediateRequestSecure()) {
return true;
}...
2
No, you don't need to change anything on your web settings.
You can leave them as
{{secure_base_url}}skin/
{{secure_base_url}}media/
etc.
2
1- check varnish port using :
sudo netstat -ltnp
in my case it's port 80
2-Update cache host using
php bin/magento setup:config:set --http-cache-hosts=xx.xx.xxx.xxx:80
here i'm using port 80 ( varnish cache port )
3- check your vcl settings ( i'm using ubuntu under: /etc/varnish/default.vcl )
backend default {
.host = "XX.XX.XX.XX";//here ...
2
In magento you should avoid inject direct script in templates like
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script>
Not like that
The correct way below
You can add path vue js to file requirejs-config.js
var config = {
paths: {
vue: 'https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue',
}
};
/*No js ...
2
You can configure separate domain for static content
Login to Magento Admin and
set "Base URL for Static View Files" and/or "Secure Base URL for Static View Files" in Stores > Configuration > Base URLs to the desired CDN domain, e.g. https://cdn.domain.com/static/
For base host configure CORS policy to allow access to cdn.domain.com from original domain
...
1
Defer JS, it means that you should load all of your js after the page dom is rendered. you can do it by Event and Observer in Magento 2.
Let me explain how you can create Event and Observer for that.
Create events.xml inside etc folder in your custom module, Like-
/app/code/Vishal/DeferJS/etc/frontend/events.xml
and paste the below code
<?xml version=...
1
Magento 2: How to add css and js in custom module in magento 2?
Add defer attribute in javascript solve some level of my issue
<script type="text/javascript" defer="defer" src="js/myjs.js"></script>
1
When creating a new custom theme, if we don't have any assets files under web folder, your theme may be ignored when executing deploy command.
answered Dec 2 '16 at 9:39
Khoa TruongDinh
28.6k99 gold badges7373 silver badges128128 bronze badges
1
You have to use absolute url instead of relative url to import font in css file like :
../font/fontfilename => http://www.yourdomain/skin/frontend/namespace/theme/font/fontfilename
1
You can load the cart via AJAX or even better: put it into the local storage and update it on ever add/remove/update
answered Apr 29 '16 at 12:36
Fabian Blechschmidt
35k88 gold badges6868 silver badges179179 bronze badges
Only top voted, non community-wiki answers of a minimum length are eligible
Related Tags
cdn × 81magento2 × 38
magento-1.9 × 16
product-images × 12
aws × 8
cloudfront-cdn × 8
magento2.3 × 6
cache × 6
cors × 6
image × 5
media × 5
javascript × 4
performance × 4
magento-2.1 × 3
css × 3
multistore × 3
varnish × 3
caching × 3
admin × 2
magento-1 × 2
full-page-cache × 2
server-setup × 2
static-content × 2
product × 1
magento-1.7 × 1