Reputation: 41
I have this weird problem. It works fine on my local machine. But the problem happens when I upload this project on the live server (in a sub-domain for testing purposes). GitHub Repository
The project has one Model (other than User), "Post"
The project has one route and one API endpoint. Initially, I should get the same results from both the web route and API endpoint. The problem is when I delete a post from the web, the API result still shows that deleted post. The API returns updated results after 20-30 minutes.
Very strange issue.
If anyone knows anything about such an issue, please help me out.
I am using Livewire
App\Http\Livewire\Posts.php
public function render()
{
$posts = DB::table('posts')
->select(DB::raw("
posts.id AS id,
posts.title AS title,
posts.category AS category,
posts.author AS author
"))
->orderBy('posts.category')
->get();
$data = [
'posts' => $posts
];
return view('livewire.posts', $data);
}
api.php
Route::get('posts', function() {
$posts = DB::table('posts')
->select(DB::raw("
posts.id AS id,
posts.title AS title,
posts.category AS category,
posts.author AS author
"))
->orderBy('posts.category');
return response()->json($posts->get(), 200);
});
Upvotes: 0
Views: 656
Reputation: 41
Actually, it was my fault. I did try
php artisan cache:clear
php artisan optimize:clear
And it did not work since there was a caching configuration in Nginx.
You know, when you are a noob at server management and end up using a nice and ready solution like myvestacp, you may end up making silly mistakes like this.
The way myvestacp is configured, it utilizes a combination of Apache and Nginx (as proxy). Without knowing the outcome, I had set the Nginx proxy as "caching" instead of "hosting-public". This is why the API result would get cached and only update after some time.
I did not face any issues so far because I did not use API before.
But thank you anyway for your time and effort.
Upvotes: 1