Ghost: Assets cached in development mode

Created on 31 Dec 2016  Â·  7Comments  Â·  Source: TryGhost/Ghost

When trying to develop a theme locally, assets are cached even when Ghost is running in development - making it very hard to work with / need to force refresh every time. Not sure if I'm doing something wrong here, or if it's a bug. I feel like it's the latter but I'm not 100%.

Steps to Reproduce

  1. Download ghost.zip
  2. npm install
  3. npm start
  4. "ghost is running in development mode"
  5. edit theme css file
  6. refresh

Expected: Shit to change

Actual: No change. Version string seems to be added: /assets/public/screen.css?v=5107093647 -- which means a force refresh is required to get the browser to load it again

Technical details:

  • Ghost Version: 0.11.3
  • Node Version: 4.2.0
  • Browser/OS: Chrome / OSX
  • Database: SQLite
api bug help wanted

Most helpful comment

Will be released in 0.11.5. Closing.

All 7 comments

Will this change be enough?

https://github.com/TryGhost/Ghost/blob/master/core/server/middleware/static-theme.js#L25

// Replace
{maxAge: utils.ONE_YEAR_MS}

// With
{maxAge: config.get('env') === 'production' ? utils.ONE_YEAR_MS : 0}

Might need change in cache middleware (https://github.com/TryGhost/Ghost/blob/master/core/server/middleware/cache-control.js) as well...

EDIT: Github allows people to "thumbs up" their own comment.....weird.

@vivekannan This fix looks good. If you could PR your suggestion, that would be great.

It might be better to check config.get('env') === 'development ? 0 : utils.ONE_YEAR_MS, because people could also run a staging system.

Should we cache during testing as well?

On Tue, Jan 10, 2017 at 5:09 AM, Katharina Irrgang <[email protected]

wrote:

@vivekannan https://github.com/vivekannan This fix looks good. If you
could PR your suggestion, that would be great.

It might be better to check config.get('env') === 'development ? 0 :
utils.ONE_YEAR_MS, because people could also run a staging system.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/TryGhost/Ghost/issues/7812#issuecomment-271442911,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHkl-ocnHHFAFo5vJhlU9YnsKjj282rsks5rQsU0gaJpZM4LYfav
.

Also, I am assuming that if there is an active theme available, the
cache-control middleware is never hit? When is the cache-control middleware
hit, generally speaking?

On Tue, Jan 10, 2017 at 12:18 PM, Vivek Kannan vivek7641@gmail.com wrote:

Should we cache during testing as well?

On Tue, Jan 10, 2017 at 5:09 AM, Katharina Irrgang <
[email protected]> wrote:

@vivekannan https://github.com/vivekannan This fix looks good. If you
could PR your suggestion, that would be great.

It might be better to check config.get('env') === 'development ? 0 :
utils.ONE_YEAR_MS, because people could also run a staging system.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/TryGhost/Ghost/issues/7812#issuecomment-271442911,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHkl-ocnHHFAFo5vJhlU9YnsKjj282rsks5rQsU0gaJpZM4LYfav
.

Should we cache during testing as well?

No.

Also, I am assuming that if there is an active theme available, the
cache-control middleware is never hit? When is the cache-control middleware
hit, generally speaking?

Cache control middleware is always hit and it adds a cache control header with max-age=0 in case of public requests.

Fixed in master branch. Issue stays open, because we need this fix in LTS branch as well.

Will be released in 0.11.5. Closing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ArthurianX picture ArthurianX  Â·  4Comments

jaguart picture jaguart  Â·  3Comments

mattferderer picture mattferderer  Â·  4Comments

albizures picture albizures  Â·  3Comments

shadowbottle picture shadowbottle  Â·  3Comments