Question

Using Ext, default Ext.Ajax add to GET-request _dc parameter. For example

GET /ConnViewProcessing/?_dc=1263286227619

How to remove this parameter?

PS: it's necessary to manually cache response to ETag and If-None-Match.

Was it helpful?

Solution

Set disableCaching option to false:

Ext.Ajax.disableCaching = false;

OTHER TIPS

Using Ext JS 4.1, and after adding the following code to app.js, the _dc parameter disappears:

// Disable _dc parameter

Ext.Loader.setConfig({
    disableCaching: false
});

// My App

Ext.application({

The proper way to accomplish that with Sencha Cmd 6.x is to set a (global) switch in app.json (because all of those hacks and overrides might interfere unnecessarily with the functionality):

"loader": {
    "cache": true
},

Then run sencha app refresh, in order to update the application's bootstrap.json.

Alternatively, one can configure Ext.Loader (at run-time):

Ext.Loader.setConfig({disableCaching: false});

When scrolling upwards and reading the actual question, concerning Ext.Ajax (per request):

Ext.Ajax.request({url: '/ConnViewProcessing', disableCaching: false});

The result: no more _dc parameters on scripted requests.

@see Sencha Cmd 6.x - The Microloader.

Note that the use of Ext.Loader has changed in ExtJS 5.

In ExtJS 5, caching can be disabled:

  • temporarily by adding "?cache" to the end of the URL
  • by setting a cookie called 'ext-cache' with the value of 1
  • or by editing the file .sencha/app/Boot.js and setting the '_config.disableCaching' property to be true (overwriting the dynamic lookup).

I am using ExtJS 4.2, but this should work for Ext JS 4.1 and on. In the proxy there is a property called noCache you should set this to false.

Ext4.define('Server',{
    extend: 'Ext4.data.Model',
    fields: [
            {name: 'id'},
            {name: 'key'},
            {name: 'value'}
    ],
    proxy: {
            type: 'rest',
            url : 'yaddayaddayadda',
            noCache: false,
            reader : {
                    type: 'json'
            }

    }
});

The reason my code says Ext4. is because I am using the sandbox mode as I move old Ext JS 3x code into 4.2

This should work with extjs 4.0.7:

Ext.Loader.config.disableCaching = false;

Setting the flag disableCaching to false (double negation - yay!) on the Ext.data.Connection should do the trick.

For more, look at the disableCaching-documentation.

(Please note that quite a few classes in Ext seem to have the option available, so you might have to muck around a bit.)

For those that want to set "disableCaching: false" in Sencha Architect 3+, here is how..:

  1. In the project inspector window, select the top node, "Application"

  2. Then in the "Config" window below that where you set the object properties, etc, select "Loader Config".. in my case I had to click the "+" to the right of this as I hadn't set any items yet. This will create a new "LoaderXX" object in the "Project Inspector" window above; Loader25 in my case.

  3. Now either select the new object in the "Project Inspector" window, or click on the right arrow beside the new "LoaderXX" (Loader25 in my case). This will take you to the properties for the object.

  4. Untick the "disableCaching" item.

Save the project and refresh the browser window, and enjoy persistent breakpoints, etc, etc in Chrome.

The only way I was able to disable _dc in ExtJS 4.2.x globally on my project:

Ext.define('Ext.data.Connection', {override:'Ext.data.Connection', disableCaching:false });
Ext.define('Ext.data.proxy.Server', {override:'Ext.data.proxy.Server', noCache:false });
Ext.define('Ext.data.JsonP', {override:'Ext.data.JsonP', disableCaching:false });

This is ugly, but any other ideas?

This is how I did this:

Ext.Ajax.request({
    url: url,
    disableCaching:false
});

I use Ext.NET on top of Ext.JS. It adds some more voodoo to Ext.js... I tried to get rid of the dc= parameter, but all mentioned configurations did not work. So, this is my uber-effective, uber-dirty solution:

Ext.Date.now = function () { return ""; }

As far as I can see, Ext.Date.now() is only used for the caching logic. So it should be relativity save.

I decided that I wanted the cache to be destroyed client side, but server side I was using my own caching mechanism (PHP's APC).

I left the _dc in the Ext ajax request, but then removed it from the REQUEST_URI, and then use the REQUEST_URI as the basis for the cache key

I found this useful: Regular expression to remove one parameter from query string

If you develop under Sencha CMD you can do like this

http://localhost:1841/?disableCacheBuster

or just

http://localhost:1841/?cache
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top