How to invalidate cache to show updated data on a custom widget in Sitefinity - sitefinity

I am setting up a custom widget in Sitefinity 13 that retrieves data from an external source and caches that data on the server-side. I need the widget data to refresh the data on whatever page it is on once that cache timeout is over, but it appears that the Sitefinity page caching mechanism will cache the rendered results of a page and won't make the call to my custom widget's controller to see if we need to update the data. I've looked into the built-in Sitefinity cache dependency functionality, like IHasCacheDependency and SubscribeCacheDependency, but that appears to be geared toward watching when a page, widget, or other item is updated through Sitefinity's mechanisms (e.g. update version of page is published). I don't see a way using that functionality to accomplish my goal.
Am I missing something with the built-in cache dependency module? What options do I have?

You have a few options:
Instead of getting the data from your controller, you can get it via javascript call. That call can be either towards the external source or, if that's not feasible, towards a proxy api controller on your site, which in turn requests the external api. This way the page will be cached, but the JS script will run and will not be dependent on the page cache at all.
Create a new page cache profile in the settings, that has no sliding expiration and lasts exactly the time you need, e.g. 5 minutes. Then set that profile as cache profile of your page. This way page cache will be invalidated exactly when you need it (time-wise).

Related

Telerik Sitefinity Add Property User

In my Sitefinity back-end there is a user section that I would like to add some setting. Something like DisplayLink where it would be a boolean value that I can set on Login of the user. Is there a way I can do that? I am using sf 14 and can't find anyway to add some setting for the user.
I believe this is what you need ...map the view externally and modify.
However keep in mind these views pull in the XHR JSON and you just expose it to the grid... Open your console and view the XHR network traffic to see the JSON object per user. There's a "Comment" field you might be able to leverage, but man the best way would be to just use a ROLE... because they can be filtered, and already come across in that JSON.
Another thing to note, is this is an OLD UI screen and likely will get revamped in the next few releases of Sitefinity rendering everything you're doing pointless... (have to re-do it with likely the new AdminApp Extensions)

load, save and reload ajax api-responses with vuex

I have a vue3-app that serves as the frontend of an asp.net core 2 api.
Much of the requested data gets used by multiple components. And in order not to make multiple identical requests, i want to store the response-data in my vuex-store if it's not in there already.
The problem is, that most of that data changes a lot, so i need to be able to tell vuex to refresh the data after some time.
But i don't want to refresh all of the requested data, since some of it doesn't need to be refreshed as often and some not at all (for example a list of countries).
So what I need is a way to tell vuex wheter i want to save the response of a specific axios request forever, or to re-request it after a set amount of time.
My questions are: Is there a plugin for this that I couldn't find? And if not, how could i implement the described functionality without rewriting it for every request?
There are some axios cache projects available:
axios-extensions (LRUCache)
axios-cache-adapter (localforage)
cachios (node-cache)
The 2 most popular currently are axios-extensions and axios-cache-adapter
Source of the chart
There is a library axios-cache-adapter that is a plugin for axios, to allow caching responses.
It is a great solution for implementing caching layer that takes care of validating cache outside of application's data storage logic and leverages it to requets library instead.
It can be used with both localstorage and indexedDB (via localforage library)

How do I know the offset for each limit?

When I use LIMIT to make pages of results, how do we usually know the offset i.e. which page should be retrieved for each request?
Via cookies?
Via a query string parameter, traditionally. URLs typically include a ?page=3 to request page 3, like you'll see all over Stack Overflow: https://stackoverflow.com/questions?page=2&sort=newest
This is something you absolutely should not do through cookies. The URL should include everything necessary to navigate to the given page. Consider a user bookmarking page three of your results, or trying to link somebody else to the page they're looking at: Using cookies to store pagination data breaks these situations completely.
Usually via request parameters in action frameworks (RoR, ZF, Cake, Django) and via state of the session in component frameworks (Prado, JSF, ASP.NET). Session is usually associated with request by a cookie.
Using session to store current page is quite common in business-oriented applications, where state of the gui might be very complicated and the practically of being able to bookmark a page - limited.

How to retrieve Salesforce Page Layout Field Properties via API?

Context:
The Web interface coded in .NET (Grantee Portal for nonprofits applying for grants) is pulling information from the Salesforce Page Layout.
The Salesforce user we use to connect the Web interface with Salesforce via API has 'view all and edit all' rights
Issue:
As it is now, if a field is defined as Read-Only on the Page Layout in Salesforce, it is still editable on the web page (the Salesforce User we use has to have 'view all and edit all' rights)
What we are trying to achieve:
IF a field is defined as Read-Only on the Salesforce Page Layout
THEN the same field should be Read-Only on the Web interface page
Question:
To achieve the above, I guess that I need to fetch the field property for the Page Layout via API. Any ideas on how to do so?
Thank you!
Izumi.
You'll need Metadata API (the set of webservices that let you add new objects, fields, picklist values or even create classes & run unit tests).
Here's the API Guide: http://www.salesforce.com/us/developer/docs/api_meta/index.htm
Depending on how often you modify layouts you might decide "screw it, I'll just use Eclipse IDE". In that case you'd download all page layouts (they're XML files), point your C# app to them and let the magic happen.
Slightly more advanced is to use Migration Tool (Ant / Java based application that can be scripted for periodic download of same stuff).
Super advanced would be to use this API guide to write it in C#. It's not rocket science (here's the specification for Page Layout object and here's the Java sample code for the operation that retrieves the metadata... sorry, no C#). Actually you might be better off looking at this example though: http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_describelayout.htm
Seeing that you'll probably want to cache this info somewhere anyway (I can't imagine your user coming to your page, having to wait for the webservice callout to complete, then having his UI rendered) - pick your poison.
Or share the work within the team (1 person kicks off with files downloaded with Eclipse, other tries to figure out the C# code to retrieve them on demand).

jMeter simulate user's progress through site

I'm a newbie to jMeter, so please bear with me.
I've been assigned the task of testing how an e-commerce website responds under load. I've managed to set up basic tests in jMeter that basically just repeatedly visit the home page, but I'd like to simulate something a bit more realistic:
User arrives on home page
User goes to catalogue page
User views product
User adds product to cart
User returns to catalogue, selects another product, adds to cart
User removes first product from cart
User proceeds to checkout
User completes checkout process.
I'm having trouble finding adequate documentation to explain how to do this. I figured out that I need a cookie manager in my test so that the user session will be maintained, but I haven't figured out how to get the user to traverse the site in a realistic use pattern (such as the one described above). Can anyone help out with this, give me some pointers as where to look for good examples, etc?
This should be no problem, record or manually create the necessary steps as HTTP Samplers, then add them into a Runtime Controller for example to execute them iteratively.
The individual steps will be executed in the order they are in the tree and, in case Cookies are used to handle session state, you might need to add the Cookie Manager to the top of the tree which will handle cookie headers for each user.
Add some timers to simulate user's think time and scale up by increasing the number of virtual users in the thread group.
Use some listener like the Aggregate Report to view the response times for every step.
Try to read http://jmeter.apache.org/usermanual/index.html at first.
Also you'll encounter the problem that Jmeter can't process dynamic pages:
http://wiki.apache.org/jmeter/JMeterFAQ#Does_JMeter_process_dynamic_pages_.28e.g._Javascript_and_applets.29
Does JMeter process dynamic pages (e.g. Javascript and applets)?
No. JMeter does not process Javascript or applets embedded in HTML pages.
JMeter can download the relevant resources (some embedded resources are downloaded automatically if the correct options are set), but it does not process the HTML and execute any Javascript functions.
If the page uses Javascript to build up a URL or submit a form, you can use the Proxy Recording facility to create the necessary sampler. If this is not possible, then manual inspection of the code may be needed to determine what the Javascript is doing.