Having issue with page cache

Kaushik Patel asked on June 11, 2019 10:26

I have one page where i am loading my favorite list. I am adding or removing favorite using webservice. Page contains repeater with querydatasource.

Now issue arise with page caching. If i modified the list and go back to package list page then it will shows old data. If i do clear cache then only it is working.

I have already set output cache to no.

Please let me know how can i clear the page specific cache from webservice. or remove cache for that page.

Recent Answers


Dmitry Bastron answered on June 11, 2019 12:14

Hi Kaushik,

In order to work with the cache from your code you can rely on Kentico CacheHelper class. Here are a few examples:

// Clear the output cache of a specific page
CacheHelper.ClearOutputCache(siteId, pageAlias, culture, true, true);

// Clear cache via dependencies
CacheHelper.TouchKey("someDependencyKeyOrDummyKey");

// Remove specific cache item by key
CacheHelper.Remove("cacheKey");

You can read more about cache keys, dependencies and dummy keys here in the documentation.

2 votesVote for this answer Mark as a Correct answer

Kaushik Patel answered on June 11, 2019 13:03

I have tried but not working.

0 votesVote for this answer Mark as a Correct answer

Roman Hutnyk answered on June 11, 2019 13:14

Kaushik,

First thing I would do is to figure out what exactly gets cached?!

  • Page output
  • web part output
  • data (query results)

Once you know this you'll have to clear cache for appropriate item.

0 votesVote for this answer Mark as a Correct answer

Kaushik Patel answered on June 14, 2019 14:24

Query result data. I have used querydatasource and then assign to repeater. Simple functionality is to generate the wishlist. But when i clear the cache then only it update the data.

0 votesVote for this answer Mark as a Correct answer

Roman Hutnyk answered on June 14, 2019 14:30

So once you know what data gets cached and where just refer to Dmitry's answer and touch cache by the key to drop a cache just for that piece of data.

0 votesVote for this answer Mark as a Correct answer

Kaushik Patel answered on June 14, 2019 14:32

I do not understand the touchkey logic for datasource or page. i tried all ways but not deleted.

0 votesVote for this answer Mark as a Correct answer

Roman Hutnyk answered on June 14, 2019 14:37

How do you add new item to wish list? - I believe you have some custom code (web part) to do that. So whenever you run the code to add/update/delete item to wish list you have to call the method, that will clear cached data.

Does it make sense?

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.