Correctly clearing cache in Umbraco 7 - caching

To be honest, I've no idea how Umbraco handles clearing its cache. I'm currently developing a property editor, and I'd like to see the result of my changes in the content section. However whenever i save my changes, build the project and refresh the page, nothing has changed.
I've tried deleting the cache folder, changing the web.config file, installing a special chrome extension to do a hard reset, clearing the entire cache, closing and opening Visual Studio and nothing seems to make any difference.
How can I make Umbraco update its cache to reflect the changes I've made to a property editor in the content section?

Umbraco joins all of the required assetts together using the Client Dependency Framework. These are then cached and stored at \App_Data\TEMP\ClientDependency\.
You can just delete these to refresh the cache.
You can stop Umbraco from doing using the CDF by putting your application in debug mode. In your Web.config, find the compilation item and change debug to equal true:
<compilation defaultLanguage="c#" debug="true" batch="false" targetFramework="4.5">
When Umbraco is set to debug mode false, calls like this will be done which get the cached version of assets: /DependencyHandler.axd?s=
When Umbraco is in debug mode, direct calls to your custom assets (and any others that are needed) will be made.
You will also need to hard refresh your browser like you were doing before or your browser may locally cache the files too.

Have you tried adding a query string to the end of the URL? Inside the plugin package.manifest your can add a random query string at end of the urls so the browser needs to re cache that url
eg. "~/App_Plugins/Javascript Url" + "?v=123432asdsa"

Related

Blazor Interopt Js in separate project doesn't refresh, even by removing cache, bin/obj

This is a cache issue I guess. Let me explain,
I have a .net6 blazor project (client server and shared project) which as a referenced project call ReactorBlazorMapbox (Razor library), which is in charge with JsInterop to play with mapbox js.
Code in progress, but works great yet. Display a map, display popup...
The ReactorBlazorMapbox project has its own JS file, called MapboxInterop.js. This file is loaded in ./_content/ReactorBlazorMapbox/MapboxInterop.js
This way, no need to reference the file in the client projet. It's embeded. Great.
My problem is, when I modify this file, nothing happend. Clear cache CTRL-F5, manualy clearing cache using inpector/Application/Cache/Delete (or local/session storage). I also removed bin/obj, clean solution, re generate projects on C# side.
My MapboxInterop.js in the browser does not refresh. (using inspector/Source)
I had to rename it MapboxInterop2.js and change my link in the import, this way it works. At least one time. But add a new file each time modification is done in this file will be time killer...
I found a work around, instead of using a embeded js interopt file from the side project, I put this one in the Blazor Client /wwwwroot/js path and add this line :
//load js from client projet path
_Module = await _JsRuntime.InvokeAsync<IJSObjectReference>("import", "./js/MapboxInterop.js");
instead of
//load js from this project
_Module = await _JsRuntime.InvokeAsync<IJSObjectReference>("import", "./_content/ReactorBlazorMapbox/MapboxInterop2.js");
this way, when re running the site with VS2022, the file in cache is refreshed.
If someone has an idea so the same thing happen for a embed project js...
FCK me :)
I forgot to check "disable cache" checkbox in the browser inspector.
But, there is a cache difference between those two files. (client vs project)...

Umbraco won't clear broken code from cache

Am creating a custom property editor for Umbraco 7. Had a a typo in the controller.js and despite what I do to clear the cache the croken code keeps showing up in the cached Dependency Handler so far I've tried:
Restarting application in IIS
Republishing Umbraco site Change
Clearing Browser cache
Change Debug="false" to Debug="true" in web.config - This worked while in debug but went
back to broken cached version when I put it back to false.
Modify ClientDependancy.config to exclude .js from fileDependencyExtensions - Again this worked while .js was excluded but went back to broken code when I added it back again.
Remove the reference to the controller from the property editors manifest. - This allowed the page to load again, but obviously the the property editor then had no controller.
Have removed datatype and and all references, restarted application and recreated it.
There has to be an easy to do this. Any suggestions?
Umbraco use the ClientDependency framework to cache the backoffice assets. CDF works by caching based on the version number in the ~/Config/ClientDependency.config file. As soon as you change the version number (just make it 1 higher or lower) the caches will be regenerated and the querystrings that automatically get added to all the backoffice assets changes.
This should bust the browser cache as well, but some browsers (Chrome especially) are very aggressive in caching assets, so on rare occasions it will also be necessary to clear your browser cache.

Prestashop smarty is not removing the cache

In prestashop I wanted to customize the default bankwire payment module. I have changed many things there in the payment.php file which is working file, but when I tried to change the smarty file(payment_execution.tpl) it did not showed any changes. I tried to remove cache from the cache folder then I tried every process which tells to remove cache, disable cache from the store. But it did not showed the changes in the frontend. I also made the same changes inside prestashop theme folder (themes/default-bootstrap/module/bankwire) but still it did not showed the changes. So can someone tell me what's the issue here?
Delete everything inside cache/smarty/cache and cache/smarty/compile
Set the option Template compilation in ADVANCED PARAMETERS > PERFORMANCE
to Recompile templates if the files have been updated
Search for all files named payment_execution.tpl in PrestaShop
If it doesn't work you'll need to check the file modules\bankwire\controllers\front\payment.php and follow the instruction $this->setTemplate('payment_execution.tpl'); step by step to see the path of the tpl (you will need a php debugger for that)

CS-Cart editing .tpl files and cache refresh

I am doing some simple hooks and some more advanced ones for a customer. (CS-Cart 2.1.4)
I have 2 websistes (production site and test site)...the two environment are not exactly the same, sadly
If I edit anything in a TPL file in the test environment, I simply save+upload on FTP and the edits are immediately visible on test website...
If I do the same edits on production environment, then save+upload on FTP, nothing changes on the storefront...
I understand it has probably something to do with template caching, and i should run mysite.com/admin.php?cc
The problem is I am the new webmaster, the old one left arguing with customer, I don't know what he has left exactly and I am afraid of refreshing production cache and "destroying" everything...(the website makes about 1M Euros/year...just to tell you what...). what if he has made some changes on the template and never refreshed cache???
Any suggestion on how to see my edits to those damned .tpl files???
To avoid clearing cache manually (by &cc) you should to change the Store mode.
Open the Admin area (any page) and look at the page bottom: http://screencast.com/t/aS2aG7oYTg
Your Store is working in Live mode and the Smart Template Engine does not check the changes in file. Click once this link and the Store mode will be changed to the "Development". Cache will be updated automatically.
P.S. You can delete var/cache and var/compiled. Store will not be destroyed :)
I solved it, by creating a clone of the Virtual Machine , editing there, and then replicated edits on main production site after being 100% sure there were no issues when clearing the cache ;-)

CSS file not updating on Azure Deploy/Publish

RESOLVED
Unbeknownst to me, Cloudflare defaults to caching all css/js files for 4 hours.
Scenario:
I add this to our front page:
<span class="test">hullo!</span>
and this to our css file:
.test { font-size:2.0em; }
I do a web deploy, OR full publish to Azure and the span appears on the front page, but not the styling. The css file for some reason does not get updated. FF, IE, Chrome and Safari all confirm it. However, after a seemingly arbitrary time, the css file get updated.
Even when I remote into the Azure VM and restart the app, the styling is unchanged. The app is running on one instance, one role. No Azure Caching is setup. Adding a querystring param to the css file link does not help. Seems like a caching issue but no clue how to resolve.
Any ideas?
"We are using Cloudflare which has a default set up to cache all CSS and JS files. It purges the cache every 4 hours which resulted in the arbitrary updates. So, even though I was adding a new query string to the end of the css file, Cloudflare still cached the old one"
Just a quick note that you should go to CloudFlare Development Mode when making changes to the static content files on your site. You can get to Development Mode to bypass the cache by going to: settings->Development Mode. You also have the option of purging your cache as an additional option, which we would only recommend if you really want to purge everything.
Looks like it's cached by your browser. Can you please try navigate to your site and press Ctrl+F5.
Maybe you can use Fiddler to see if the CSS had been cached, or not updated, or some error when download.
This issue is resolved.
We are using Cloudflare which has a default set up to cache all CSS and JS files. It purges the cache every 4 hours which resulted in the arbitrary updates. So, even though I was adding a new query string to the end of the css file, Cloudflare still cached the old one.
I have dealt with this and I will tell you that from my experience in Chrome you can set a setting that disables the cache in the developer tools, however, I've noticed that unless you have the dev tools window open when you hit Ctrl+F5 it doesn't reload the cache. In IE there is a global setting in the dev tools that will make it redownload everything every time. In Firefox there is also a setting in the dev tools that will require it to download and not use the cache.
One way that you can test this, and how I test this, is by running Fiddler and watching if it does a full download of all your files or if it's caching.
From what I've experienced is that this is truly a browser caching issue and not anything to do with Azure.

Resources