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

Bypass cache for exposed routes in debug mode #362

Merged
merged 1 commit into from Dec 1, 2019

Conversation

nesk
Copy link
Contributor

@nesk nesk commented Sep 26, 2019

I'm having a hard time with this package in local environments, I've included the JS script like this:

<script src="{{ asset('bundles/fosjsrouting/js/router.min.js') }}"></script>
<script src="{{ path('fos_js_routing_js', { callback: 'fos.Router.setData' }) }}"></script>

However, whenever I add, change or remove a route in config/packages/fos_js_routing.yaml, I must run rm -rf var/cache/*/fosJsRouting (bin/console cache:clear doesn't work) to see the applied changes in the response of fos_js_routing_js.

It seems like ConfigCache is the culprit, so I've made a simple change to bypass the cache when the debug mode is enabled.

@stof
Copy link
Member

stof commented Sep 26, 2019

the right solution instead would be to add a cache resource invalidating the cache when changing the exposed routes too.

@nesk
Copy link
Contributor Author

nesk commented Oct 1, 2019

@stof Couldn't agree more, but until someone is willing to do this (seems to require a bit of work) maybe we could merge this to solve the current issue?

@tobias-93 tobias-93 merged commit 6793326 into FriendsOfSymfony:master Dec 1, 2019
@tobias-93
Copy link
Collaborator

Thanks @nesk, I see no harm in ignoring the cache in debug mode so I've merged this.

@timwsuqld
Copy link

Further to my bug report in #389, looking at the code, ConfigCache should already be working correctly. @nesk did you look in the var/cache/dev/fosJsRouting/data.json.meta file to check if it was seeing config/packages/fos_js_routing.yaml file as a Resource? For example, I can see /srv/www/config/routes/0-fos_js_routing.yaml is listed in my meta file, which correctly reflects our routing files.

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

Successfully merging this pull request may close these issues.

None yet

4 participants