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

Improve assets cache #8117

Closed
alansemenov opened this issue May 27, 2020 · 11 comments
Closed

Improve assets cache #8117

alansemenov opened this issue May 27, 2020 · 11 comments
Assignees
Projects
Milestone

Comments

@alansemenov
Copy link
Member

alansemenov commented May 27, 2020

@alansemenov alansemenov added this to the 7.4.0 milestone May 27, 2020
@sigdestad
Copy link
Member

Simply drop the cache header (or perhaps Even force no caching)

@poi33 poi33 added Improvement and removed Bug labels May 27, 2020
@poi33
Copy link

poi33 commented May 27, 2020

This is a built in feature on all browsers, disable-caching of assets.
Even if we remove the caching headers the browser can still force caching.
I cant find any development environment that forces the browser to not cache, it is usually a flag or an option to add custom header data.

I suggest to add documentation that the developer needs to disable the cache in the browser.

@sigdestad
Copy link
Member

Disabling browser cache can be done easily via http cache headers

@rymsha
Copy link
Contributor

rymsha commented May 27, 2020

Unfortunately, not @sigdestad Browsers are "smart" and like to cache anyway. https://blog.chromium.org/2017/01/reload-reloaded-faster-and-leaner-page_26.html

I am also not sure developers will be happy to see noticeable performance drop for page loading (not cached .js and .css files must be always parsed and executed). Even when development mode tis turned on "because it is always turned on on developer's machine". It is certainly a trade-off: one bad experience against another bad experience.

None of frameworks I know change cache-control headers for "static" files in development mode. Because disabling cache in browser is a way more flexible approach.

  • It allows to check that custom cache-control settings (set in Headers-Filter for instance) work as expected regardless of mode.
  • It helps developers to see headers sent from XP as they would be in production.

@sigdestad
Copy link
Member

To see how work in production, the developer can simply run XP without dev mode :-)

@rymsha
Copy link
Contributor

rymsha commented May 28, 2020

To see how work in production, the developer can simply run XP without dev mode :-)

But I don't see how it is better than toggle checkbox in the browser. IMO toggle checkbox in browser is simpler as developer does not need to stop XP instance, change mode and start instance again.

@rymsha
Copy link
Contributor

rymsha commented May 28, 2020

To sum up

  • it always (often unnecessarily) slows down page loading/rendering in dev mode
  • it modifies XP behavior between dev and prod mode
  • it does not always work
  • it requires a bit extra code testing and support
  • it has a robust alternative

Better to document dev mode in our reference and mention browser checkbox there enonic/doc-xp#148

@sigdestad
Copy link
Member

Hmm... Are you saying devs are familiar with disabling cache? I never heard about this before now?

@poi33
Copy link

poi33 commented May 29, 2020

Hard refreshing is one of the first thing i teach to new developers.
Beacause one of the first issues with css is that it does not update.

@rymsha
Copy link
Contributor

rymsha commented May 29, 2020

@rymsha rymsha removed this from the 7.4.0 milestone Jul 14, 2020
@rymsha rymsha added the To Be Discussed Issues that require additional discussion label Sep 25, 2020
@rymsha rymsha removed the To Be Discussed Issues that require additional discussion label Jan 21, 2021
@rymsha rymsha changed the title Assets are cached in dev mode Improve assets cache Jan 21, 2021
rymsha added a commit that referenced this issue Jan 21, 2021
rymsha added a commit that referenced this issue Jan 21, 2021
@rymsha rymsha self-assigned this Mar 26, 2021
@rymsha rymsha added this to To do in 7.7.0 via automation Mar 26, 2021
@rymsha rymsha moved this from To do to Done in 7.7.0 Mar 26, 2021
@rymsha rymsha added this to the 7.7.0 milestone Mar 26, 2021
@rymsha
Copy link
Contributor

rymsha commented Mar 26, 2021

In dev mode assets endpoint always has new fingerprint.

follow up task #8612

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
7.7.0
Done
Development

No branches or pull requests

4 participants