How to "purge" preloadedJs?

papi Jo's picture
Forums: 

I am currently testing my new version of DialogCards (DC), using Drupal 7 and the development folder. Of course, in the process of testing I frequently edit my dialogcards.js file.

On my localhost all is OK, the changes I make to dialogcards.js are immediately taken into account when I view a DC activity in my browsers (Firefox or Chrome).

However, I have an online Drupal test site configured exactly like the localhost Drupaltest site... but things do not happen as expected. When I make changes to dialogcards.js online (e.g. using WinScp to edit that file or transfer a new version from local to distant), those changes are not reflected. My DC keeps using the "preLoaded/cached" version. I found a --- cumbersome --- workaround. In the DC library.json file I re-name "preloadedJs": [{"path": "js/dialogcards.js"}] to "preloadedJs": [{"path": "js/dialogcards01.js"}] and of course I rename dialogcards.js to dialogcards01.js. But I need to do this (renaming to dialogcards01, dialogcards02, dialogcards03,...) each time I make changes to the script inside the js file.

Questions:

- Where do the preloadedJs files reside on my server? I can't see them in the database or in the H5P folder anywhere.

- Why do things work OK on my localhost but do not work on my online site?

- Is there an easy way to "purge" preloadedJs file?

PS.- This problem seems to have arisen recently, I did not notice it with my previous tests.

icc's picture

You should always be able to purge using Ctrl+Shift+Delete and clearing the browser cache. However, this should not be necessary. 
I suspect this may be the web server setting a "Cache-Control" header automatically for .js and .css files, you should be able to see it in the Network tab of the developer tools in your browser. When selecting the request for the .js file look under the Response Headers section.
To avoid this there should an option "Disable cache" in the developer tools, usually in the Network tab, but could be under Settings as well. This only works as long as the developer tools are open. 

papi Jo's picture

Thanks for the hint. In "normal" internet usage, caches are quite useful, but they are a nuisance for developers. And there are so many places to look for them. I had indeed emptied my browser cache, my Drupal caches, but my web server uses a "varnish cache" which I finally managed to purge!