this post was submitted on 26 Mar 2025
1 points (100.0% liked)

General Discussion

0 readers
2 users here now

A place to talk about whatever you want


This is a forum category containing topical discussion. You can start new discussions by mentioning this category.

founded 6 months ago
 

Hi guys, I act upvoting a post on the home page, then go to another page, and then go back by pressing the back button of my browser. Maybe the browser caches data. The post that I upvoted before did not change, and when I checked the data, it was still old data. Only reloading the page will update the data. Is there any way to fix this? I try to use pageshow event to update post list but not working

$(window).off('pageshow').on('pageshow', async function (event) {
		if ((event.persisted || (performance.getEntriesByType("navigation")[0]?.type === "back_forward"))) {
			const params = utils.params();
			const query = {
				page : 1,
				...params,
				_t: new Date().getTime()
			}
			await api.get('/search/keyword' , query, function (err, data) {
				if(err) return;
				app.parseAndTranslate('partials/posts_list', { posts: data?.posts }, function (html) {
					$('.topics-list').html(html);
				});
			})
		}
	});
no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here