Skip to content
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

retype watch does not refresh upon changes in CSS referenced in _includes/head.html #324

Closed
rdewit opened this issue May 5, 2022 · 5 comments
Assignees
Labels
question Further information is requested

Comments

@rdewit
Copy link

rdewit commented May 5, 2022

In order for us to override the default colors of retype, we have a custom CSS that we reference in head.html like this:

<link href="/static/css/retype-override.css" rel="stylesheet" />

When I make a change in the CSS, retype appears to detect this and reload as can be seen in the terminal (during a retype watch) but it does not refresh the browser window (like it does when I make a change to an .md file for example).

It would be nice if the browser window refreshed when changes in the .css get detected.

@geoffreymcgill geoffreymcgill self-assigned this May 5, 2022
@geoffreymcgill geoffreymcgill added the question Further information is requested label May 5, 2022
@geoffreymcgill
Copy link
Collaborator

The issue is likely caused because the browser is temporarily caching the css file.

You can clear the cache by force reloading the page or by adding a cache-buster suffix to the css file path. Something like this:

<link href="/static/css/retype-override.css?v=1.0" rel="stylesheet" />

Then just manually increment the cache buster when you want to force a complete reload the of the .css file.

<link href="/static/css/retype-override.css?v=1.1" rel="stylesheet" />

Hope this helps.

@rdewit
Copy link
Author

rdewit commented May 5, 2022

Unfortunately that is not really a solution. Ideally, the Kestrel server would add something like a Cache-Control: no-cache response header (and certainly not a 304 Not Modified status code.

As you probably know, it's currently quite hard to override the current retype.css (to change colors for example), so in order to efficiently create new CSS to override (and add to) the existing CSS, it would be very convenient if the changes show up immediately when saving the CSS file.

@rdewit
Copy link
Author

rdewit commented May 5, 2022

For now I've got the following workaround (just in case anyone else has a similar issue):

  • Install browser-sync
  • Run: browser-sync start --no-open --files "static/css/*.css" --proxy http://localhost:5000/ --reload-delay 1000

@geoffreymcgill
Copy link
Collaborator

Thanks for the update and sharing the browser-sync work-around. We have logged the issue and will investigate a fix to get this working within Retype.

@geoffreymcgill
Copy link
Collaborator

As of Retype v3.0, there is a new {{ nonce }} token that will be replaced with a unique value, such as 3.0.1.739057412015.

The {{ nonce }} is good for building cache-busting URL's, such as:

<link href="/static/css/retype-override.css?v={{ nonce }}" rel="stylesheet" />

Which will be emitted as the following in the generated HTML:

<link href="/static/css/retype-override.css?v=3.0.1.739057412015" rel="stylesheet" />

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants