Bug Report, Spectra’s Caching
-
Problem: Hello, found a bug with spectra. This causes bugs in external code bases that are user based. In my case, the bug appeared when I added ratings to the grid via hooks. Then I logged in and would page through the post grid. The first user who would visit the second page using the pager, would see their results. But the second user who would visit the second page using the pager would see the first users results. However when I refreshed the page, I would get the correct users results (this indicates Specta’s cache is different for page numbering, or page refreshes). I had disabled all caches, disabled everything and the bug continued. I also noticed that spectra correctly passes on the query string to the pages. (hint to the solution 2).
Impact: Spectra Is Using Cache Differently For Updates and Page refreshes to their Post Grid. This also indicates that some requests ajax paging is being cached more then when the page firsts load. This means there is an opportunity to optimize the plugin, bu using the same cache for both. It would also make your code more consistant.
How to Reproduce: Add Post Grid to a page. Using hooks, create a plugin that inserts user_id into the post_Grid. Then as a logged in user, visit the page. Then hit the pager a bunch of times. Now in another browser, with the user_id logged out, visit the page with the grid and no page number as a query string attribute. You will notice The user_id will always be right on the first visit. Now using AJAX, click on the pager a number of times. You will eventually see a page where the user_id changes to the other users number (not 0).My Solution: I spent 8 hours trying to locate the source of the issue, and even disabled all other plugins. Still happened. I eventually added a user_id to the query string (since votes are based on user) and I redirected if this user_id if the user_id didn’t match the current user. This meant that this cache buster would always be user based, but you can use any cache buster string that is related to the dependency of your data. Because the page query string attributes is passed into the AJAX. That fixed the problem.
I should of tried this first, as this would fix all caches. But oh well, atleast I found the issue with Specta.
The topic ‘Bug Report, Spectra’s Caching’ is closed to new replies.