Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:

TOPIC: prevent .js caching?

prevent .js caching? 4 years 5 months ago #75132

  • mmirasol
  • mmirasol's Avatar
  • Offline
  • Senior Lime
  • Posts: 42
  • Karma: 0
Hello,

Is it possible to prevent .js caching when testing surveys? I'm currently working on a survey using template.js to do custom programming for my questions and I observed that if I put

$('div.'+qcode).hide(); it hides the question initially,

Then, I commented this line to see my values in my hidden question and later uncommented it to rehide the question but it didn't hide the question anymore.

Please advise. Thanks.
The administrator has disabled public write access.

prevent .js caching? 4 years 5 months ago #75149

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 9298
  • Thank you received: 1330
  • Karma: 386
Yep,

You need to reload the HTML with F5 (with FF). But js cache can't be manipulated with LS I think, it's difficult to do.

I think you can put some cache config in the apache configuration.

Denis
Assistance on LimeSurvey forum and LimeSurvey core developpement are on my free time (Say thanks ?).
A bug not reported is a bug not corrected. | Please, read the documentation | La doc en français à besoin de vous
The administrator has disabled public write access.

prevent .js caching? 4 years 5 months ago #75156

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6210
  • Thank you received: 1376
  • Karma: 539
I think this is a matter of browser caching, not anything to do with LimeSurvey.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

prevent .js caching? 4 years 5 months ago #75159

  • Ben_V
  • Ben_V's Avatar
  • Offline
  • Platinum Lime
  • Posts: 1805
  • Thank you received: 445
  • Karma: 111
I think you can put some cache config in the apache configuration.
Ej. in .htaccess file:
<filesMatch "\.(js|css)$">
<ifModule mod_headers.c>
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
</ifModule>
</filesMatch>
</FilesMatch>

If doesn't work because mod_headers not available try:
<FilesMatch "\.(js|css)$">
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
</FilesMatch>
Benoît

EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
All LS releases => bit.ly/1VMuTDu | 2.06lts => bit.ly/1Qv44A1
Demo surveys => bit.ly/20NW9V8 (already included in /docs/demosurveys)
The administrator has disabled public write access.

prevent .js caching? 4 years 5 months ago #75189

  • mmirasol
  • mmirasol's Avatar
  • Offline
  • Senior Lime
  • Posts: 42
  • Karma: 0
Thank you, benitov, tpartner and Shnoulle. =)

I've tried reloading the browser, clearing the cache (using FF), putting this in my .htaccess file.
<filesMatch "\.(js|css)$">
FileETag None
<ifModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</ifModule>
</filesMatch>
Still no luck though. At the moment, I had to manually set display:none for each question thru css. Any other ideas?

I really don't understand why the same code works when I run it on firebug, but doesn't work when I put it in my template.js file.
Last Edit: 4 years 5 months ago by mmirasol.
The administrator has disabled public write access.

prevent .js caching? 4 years 5 months ago #75208

  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5984
  • Thank you received: 368
  • Karma: 260
I guess this is still a browser caching issue. Maybe at some browsers - perhaps with some add-ons - you can specify files which should not be cached?
I simply use F5 to reload a page in Firefox and it works fine, the browser grabs the new version of the file instead of taking the cached one.

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

prevent .js caching? 4 years 5 months ago #75323

  • mmirasol
  • mmirasol's Avatar
  • Offline
  • Senior Lime
  • Posts: 42
  • Karma: 0
Perhaps. But I probably did everything to get rid and prevent caching and I do F5 all the time so I think I must have missed something in my code or there's a conflict somewhere. Still, a big thank you to everyone. =)
Last Edit: 4 years 5 months ago by mmirasol.
The administrator has disabled public write access.

prevent .js caching? 4 years 5 months ago #75486

  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5984
  • Thank you received: 368
  • Karma: 260
You're welcome!

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.337 seconds
Imprint                   Data Protection Statement                  Revocation information and revocation form