onefastbusiness
Forum Replies Created
-
Hey… I don’t have any caching on my website since it’s very lightweight and has zero images and I want to be able to update my content real-time so that my users always get the latest version of the content.
Yes I am using custom login form (Forminator) because I don’t like the flow of wordpress and it might get users confused and also it’s a break from my website design.
Anyways, I found a temporary solution so anyone can use it that has this problem.
It seems that only the EXACT url path is cached so if you can modify it without affecting its destination that solves the problem.
For example: https://www.mypath.com?123
So I decided to modify all my existing membership links with a short JavaScript code that I added at the end of every page (with Insert Headers And Footers plugin)
Basically what it does is it finds all my membership links (which is easy to do because they all have “-member-” in their URL and just appends the timestamp at the end. Baiscally it turns this:
https://www.mysite.com/some-member-link
into this:
https://www.mysite.com/some-member-link?1639388878443And since timestamp is always different there is no way of ever caching my membership links.
JavaScript code is below:
<script> // fixing caching problem for Content Control plugin const allLinks = document.querySelectorAll('a'); allLinks.forEach((link) => { if (link.href.includes('-member-')) { link.href = link.href + '?' + (new Date()).getTime(); } }); </script>