Hot answers tagged

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 ...


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.


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-...


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.


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.


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


Only top voted, non community-wiki answers of a minimum length are eligible