Own code & versioning
-
This plugin looks like it is could be what I need for my issue. On my site some pages are very different depending on whether the user is logged in or logged out. Browser caching is causing confusion because a user may log in but then be shown the logged-out version of a page, complete with login panel!
This plugin offers a solution: I can write code like:
prevent_browser_caching( array( 'assets_version' => is_user_logged_in() ? ‘logged_in’ : ‘logged_out’ ) );
This should lead the browser to display the correct version of the page. Note that both versions of a page could be cached for some days and displayed as appropriate.
However, the returned text completely replaces the version number, thus:
With plugin not active: css?ver=3.1
With plugin active without own function: css?ver=3.128536473Note that if the css is updated, this will force the new version of the page, even if the plugin has not updated the number it appends. In the above example, it might become css?ver=3.228536473
However, with my code above, I get: css?ver=logged_in
That is the returned string completely replaces the version number rather than being appended to it.I think it should be appended so I get: css?ver=3.1logged_in
That way the displayed page will be updated if the css is updated, even if the logged in/out pages were available in the cache.
Thoughts?
- The topic ‘Own code & versioning’ is closed to new replies.