How To Use Caching In Dojo? - caching

What I am Doing?
I have Dojo widget which has call to server. From that Http request it gets list of product code . These product codes are shown in Filtering Select drop down.
What problem I am facing
I want to do caching of those product codes so that server request is not raised every time. Product code list is quite large (10 K product codes) so cookie is not good option
Is there any way to do caching in Dojo ? Any learning resource would be helpful.

Related

performance testing of add to cart product in magento using jmeter

I am creating a JMeter Script to add products into the cart for the Magento2 website. Post request is executing without any error but the product isn't displaying into cart after that request.
Check snap of post request
JMeter automatically treats HTTP responses with status codes below 400 as successful, it doesn't know anything about Magento or product adding to cart. If you need to introduce an extra check that the product is there - you need to add Response Assertion
In the absolute majority of cases the main reason for "failing" requests is missing or not properly implemented correlation of the dynamic parameters:
Check that your ${form_key} JMeter Variable has anticipated value using Debug Sampler
Your request URL looks very suspicious, it might be the case you need to extract the URL for adding this particular product from the previous response as well
Don't forget to add HTTP Cookie Manager to your Test Plan
Also be aware that there is a Magento performance-toolkit containing benchmark.jmx script which you can use as the reference/basis for your own tests
You likely need to handle the dynamic values associated with cart identifier with the session. I will save you some time however, architecturally when Magento issues the cart is a known antipattern - every time I see Magento it is a default cart model.
What does this mean, the "default cart...?" This is a pattern of too early allocation of a resource. Twenty percent or fewer of visitors will ever use the cart, yet 100% of the population are allocated carts. You now have cart objects and cart resources which are dead resource allocations in the system that have to be managed, which includes clean up after a period of time/time out.
The performant design pattern is a just-in-time cart which is only created when the use either adds something to the cart or selects the cart icon to view the contents of a stored cart. Going along with this, the number of items in a perpetual cart should be persisted in a local cookie value rather than require a "pull" of the cart every time the user visits the site.

Queries with queues on Laravel

At some pages there are some not important queries (products views increments , grab facebook likes) that have to run after the full load page just for improving the performance
Until now I made that kind of jobs with ajax on $( document ).ready() .
How can I use Event or Queues features of laravel for achieving that.
Is possible to pass an object (like an eloquent collection) also?
Thank you.
A queue is a server side processing event, that is meant to occur after the user does something. For example, after the user signs up, the system 'queues' an email, so it can return to the user quickly, and send the email later.
You cannot use Laravel 'queues' for page loading. This is a user-side event that needs to happen immediately.
Your use of ajax to load slow elements after the initial page load is good. There are other ways to optimize page loads (such as reducing database queries, html + css + js compression etc).

From AJAX action, returning JSON or HTML is preffered?

On my website landing page, I am calling various AJAX actions.But the performance is poor as of now.These actions are
To get latest articles
To get latest news
To get latest Jobs
To get recent added users etc.
I am showing all this information in dashboards for each AJAX actions.
My question is,
From my AJAX actions, should I return the HTML or JSON? Which one would be better in performance and maintainance point of view?
I have following few points on these approaches -
HTML
Pros-
1. Will be easy to code
2. Easy to maintain.If there is any UI change in dashboard, with HTML it would be easy to do.
Cons-
1. Performance hit as complete HTML would be sent on client side.
JSON-
Pros-
1. Good performance as data transfer size would be less.
Cons-
1. UI change in dashboard would be comparatively diffcult as I need to change JS code rendering logic.
I want to understand if my assumptions are correct or not.And if there are any other points in these approaches?
Loading and embedding HTML directly as opposed to just sending the data and transferring it into a DOM structure client-side should not be so much different when it comes to performance.
Usually the greatest performance “killer” in an HTML page environment are HTTP requests – they take close to “forever” compared to all other stuff you do client-side. So if you have to pull data for multiple such widgets, it might be a good idea to encapsulate those data transfers into just one HTTP request, and have the different widgets read their data from there once its loaded. And for that, a data format like JSON might be preferable over HTML.

Magento top link cart is cached by varnish

I am using Varnish to enhance performance on my Magento store.
My problem is it that Varnish is caching the top links number of items in Cart.
I was thinking to use a Ajax call after page loading, not sure how to implement,
suggestions?
Thanks
If you want to implement this via ajax, here's one possible approach:
Backend work:
For each action which modifies the number of items in the cart, observe the event and fire a method that will update a cookie on the client with necessary data you need. You can do something simple and store a JSON structure: {"cartItem": 2, "isLoggedIn": false}. Some events to observe:
controller_action_postdispatch_checkout
controller_action_postdispatch_customer
checkout_onepage_controller_success_action
Create a controller/action that will return the exact same data structure (as well as set the cookie while its at it).
Frontend work:
On DOM ready your code should look for the cookie set in the backend. If it doesn't exist, make an ajax request to the controller to fetch it.
Once it has the necessary data, update the values in the DOM as necessary
You'll want to make sure you listen to the all the necessary events. Using the cookie will help speed things up on the client side and reduces the number of HTTP requests the browser needs to make.

ajax architecture question

I have a page with 3 layers, one for navigation, one for database records and one for results. When I click on a database record, the results are displayed in the result layer via ajax. For navigation, the links will simply be different queries. I am wondering if it would make sense to have each different query be sent as ajax data and palced into the records layer, or rather to have the query appended to the php file each time. Which is the more efficient approach?
Well, sending a different AJAX request will be recommended as per my point of view. As
Performance wise, it will rather reduce the response times, as only the POST data is sent and databytes recieved. The page can then format it, one it receives an XMLHttpResponse
Security wise : I prefer using POST than GET as it gives at least some opaqueness as to what is being passed as a parameter and not anyone can just edit the url and play around. Plus, you don't have the URL length restriction while passing parameters in POST.
So, i'd say fire an XMLHTTPRequest
each on each link and display the
response in the Results layer
(pane/div) on the page.
I think you question is quite unspecific and confusing.
What is "appended to the php file"?
Are you really concerned about efficiency? I mean, how fast should the results be displayed? Or are you concerned about the server workload?
Have you read this tutorial? Prototype introduction to Ajax
I think it should answer most of your questions and give enough example code to continue.

Resources