NetTalk Central

Author Topic: how to add a css file to the webservice documentation page?  (Read 4591 times)

AtoB

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • Email
how to add a css file to the webservice documentation page?
« on: August 09, 2016, 11:32:47 AM »
Hi all,

I want to add a css file (or is there a better way) to the generated help pages for the webservice methods. I modified the prompts of the "global" netwebserver procedure to add a script and the generated code shows the addition (file is "broek.css"):

  IF(true)
    s_web._SitesQueue.Defaults.HtmlCommonStyles = |
      s_web.AddStyle(clip('shoestrap3') & '/theme.css',true) &|
      s_web.AddStyle('broek.css') &|
 ...

but the actual served page doesn't contain this (not even after F5 :-))

what am I doing wrong?

TIA,
Ton


AtoB

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • Email
Re: how to add a css file to the webservice documentation page?
« Reply #1 on: August 09, 2016, 10:42:03 PM »
Partially solved:

Still haven't got a clue what cached the page (I've pressed F5/ctrl-F5 a dozen of times), but this morning it somehow refreshed and now is using the added .css file!

So if someone still can enlightnen me what to do the next time, be my guest !

Regards,
Ton

AtoB

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • Email
Re: how to add a css file to the webservice documentation page?
« Reply #2 on: August 10, 2016, 04:17:01 AM »
I think I've found it, the served page uses a "?c=1" tag/attribute/parameter (?), when I remove this,  the stylesheet file was applied !

now finding out why ...

regards,
Ton

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: how to add a css file to the webservice documentation page?
« Reply #3 on: August 10, 2016, 11:41:18 PM »
Hi Ton,

>> I want to add a css file (or is there a better way) to the generated help pages for the webservice methods.

Adding your own CSS files to the system is recommended and probably some thing that most apps have done. It's so common that the wizard even includes one for you <g>.

Typically css files are added not via embed code, but via the web server prcoedure, nettalk extension, styles / files tab.

>> I think I've found it, the served page uses a "?c=1" tag/attribute/parameter (?), when I remove this,  the stylesheet file was applied !

yes, but this is a red herring. (The c=1 parameter is a technique to force the browser to ask the server for the file in case it has changed. But in this case it is _server side_ caching, not _client side_ caching which was your root problem, so which _changing_ this parameter has the side effect of fetching the new file, that's an accident, not by design.)

So the real issue is that you had server-side caching on while you were editing javascript or css files. It's recommended that while editing these files you click the "debug" button on the Web Server procedure, NetTalk Extension, Performance tab. This turns off all caching to make things easier.

Once editing is done you can switch it back to high performance (and run gzipall at this point as well.)

Cheers
Bruce

AtoB

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • Email
Re: how to add a css file to the webservice documentation page?
« Reply #4 on: August 11, 2016, 02:03:55 AM »
Hi Bruce,

somehow it seems I can make a living of dealing with side effects :-)

But still a little confused:

- the "?c=1" is used to clear the client side cache and should/could be modified with a new release, or is there some other mechanism that refreshes the client side of things automatically (in production environments)?

- for the production environment : suppose I change a .css file on a new release (that is cached on the server side by default), how should I make sure the new css file is "replaced" on the server, or how should I clear the cache server side?

TIA,
Ton

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: how to add a css file to the webservice documentation page?
« Reply #5 on: August 12, 2016, 01:11:11 AM »
>> - the "?c=1" is used to clear the client side cache

no, that's not quite correct.
Basically the browser looks at the URL and decides whether to use the client-side cache, or not. Actually there are 3 possible options;
a) just use it
b) check with the server, tell the server we have the file and ask if it's still ok
c) ask for the file.

Adding parameters to a request makes it use b) instead of a). So adding the parameter (?c=1) has the effect of _any_ parameter.

The parameter itself is on or off depending on a setting on the WebServer Performance tab. (Auto-check cached files.)

>> - for the production environment : suppose I change a .css file on a new release (that is cached on the server side by default),

Server side cache only lasts while the Exe is running, so if you update the css or js in production just stop and restart the server. (If you have xFiles in the server then the sessions are saved while off, so the user doesn't see it go down.)

cheers
Bruce



 how should I make sure the new css file is "replaced" on the server, or how should I clear the cache server side?

AtoB

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • Email
Re: how to add a css file to the webservice documentation page?
« Reply #6 on: August 15, 2016, 11:54:29 PM »
that explains a lot,

thanks