Skip to content

Name of cache busting parameter #1570

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
millette opened this issue Aug 1, 2016 · 14 comments
Closed

Name of cache busting parameter #1570

millette opened this issue Aug 1, 2016 · 14 comments
Labels
Accepted Issue has been reproduced by MathJax team Fixed Test Not Needed v2.7

Comments

@millette
Copy link

millette commented Aug 1, 2016

Hello, I'm new to MathJax, but checked older (and closed issues) and I don't think this was brought up yet.

Long story short, I'm using CouchDB to serve the MathJax files for a CouchApp (instead of nginx or another http server). The rev parameter that's added to the automatically loaded JS files is interfering with CouchDB's semantics.

Searching this source code, I see rev is only used in a couple of places, and only for cache busting. Correct me if I'm wrong.

May I suggest changing rev to ver? From what I understand, if shouldn't change anything in MathJax, but it would stop interfering with CouchDB. If you feel using another hardcoded parameter name could lead the further problems down the line, we could make it an option.

For now, I'm using this workaround:

window.MathJax = {
  AuthorInit: function () {
    // couchdb really doesn't like the ?rev argument
    // appended by the MathJax loader;
    // taking care of that here (side effects, perhaps?)
    window.MathJax.cdnVersion = ''
  }
}

I'm ready to write a quick patch for the 1st option if this solution is accepted (s/rev/ver/). I can also try to make it an option if that's preferable.

Thoughts?

@pkra pkra added the Question label Aug 1, 2016
@pkra
Copy link
Contributor

pkra commented Aug 1, 2016

Could you provide some background on why this is causing problems with CouchDB?

@millette
Copy link
Author

millette commented Aug 1, 2016

According to the Officlal CouchDB Docs:

Query Parameters:
rev (string)
Document’s revision. Optional

rev is used to fetch CouchDB internal revisions for an attachment, and the name of this query parameter can't be changed (without recompiling erlang, I guess). I also inquired on #couchdb (Freenode) and got the same reply.

@millette
Copy link
Author

millette commented Aug 2, 2016

In effect, the JavaScript files autoloaded by MathJax aren't found (404) when attached to a CouchDB document since the specified rev doesn't exist according to it. Using ver or any other parameter name would probably work, only rev conflicts.

@dpvc
Copy link
Member

dpvc commented Aug 2, 2016

I don't have any problem with changing rev to ver; it is only used to break caches, as you point out. @pkra, what do you think?

I was going to suggest essentially the patch that you are already using (I didn't see it in the email version sent to me when you initially posted, so I assume you edited it afterward).

Alternatively, you could use

var MathJax = {
  AuthorInit: function () {
    MathJax.Ajax.fileRev = function (file) {
      var ver = MathJax.cdnFileVersions[file] || MathJax.cdnVersion || '';
      if (ver) ver = "?ver="+ver;
      return ver;
    }
  }
}

which does the change you are asking for.

@millette
Copy link
Author

millette commented Aug 2, 2016

Ah, replacing the fileRev(), less magic than my workaround, thanks.

CouchDB might not be the most popular web server, it's probably less work to change the parameter name than to add a description of the workaround to a FAQ on in the README.

The patch would be trivial but let me know if you want me to provide it.

With the possibility of changing fileRev(), I hereby retract my suggestion to make the "rev" parameter changeable thru an option :-) A new hardcoded value will do just fine.

@dpvc
Copy link
Member

dpvc commented Aug 2, 2016

It is probably easier for us to do it, as contributed changes require an SLA, which is too much of a hassle for this one-word change.

@millette
Copy link
Author

millette commented Aug 2, 2016

I wouldn't want copyright to swap 2 letters :-)

@dpvc
Copy link
Member

dpvc commented Aug 2, 2016

Right. But administrators like to have all the forms. Thanks for your contribution!

@pkra
Copy link
Contributor

pkra commented Aug 3, 2016

@pkra, what do you think?

I don't mind either way. @zorkow?

@dpvc dpvc added this to the MathJax v2.7.0 milestone Aug 21, 2016
dpvc added a commit to dpvc/MathJax that referenced this issue Aug 21, 2016
…nflict with anyone's server usage). Resolves issue mathjax#1570.
@dpvc
Copy link
Member

dpvc commented Aug 21, 2016

The issue1570 branch of my fork of MathJax includes the change.

@dpvc dpvc added Ready for Review Accepted Issue has been reproduced by MathJax team Test Not Needed and removed Question labels Aug 21, 2016
dpvc added a commit that referenced this issue Aug 24, 2016
Change 'rev=' to 'V=' in cache breaking code.  #1570
@dpvc
Copy link
Member

dpvc commented Aug 24, 2016

==> Merged

@dpvc dpvc added Merged Merged into develop branch and removed Ready for Review labels Aug 24, 2016
@dpvc dpvc closed this as completed Aug 24, 2016
@millette
Copy link
Author

Thanks!

@zorkow
Copy link
Member

zorkow commented Aug 24, 2016

I'm fine with that.

@dpvc dpvc added v2.7 Fixed and removed Merged Merged into develop branch labels Jan 4, 2017
@smonsarr
Copy link

smonsarr commented Jun 9, 2021

We just got bitten by this.
In our content provider ?V=xxx means select a specific "view", all resources loaded with ?V=2.7.9 are met with 404.

Have changed this to :
if (V) {V = "?mjv!"+V}

This has the benefit of not being a standard query parameter, and therefore a lot less likely to interfere with other systems while fulfilling the required effect of making the URL to MathJax resources reflect the current version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Issue has been reproduced by MathJax team Fixed Test Not Needed v2.7
Projects
None yet
Development

No branches or pull requests

5 participants