Laravel 5 on Shared Host Problems - php

I am trying to deploy my website with laravel on web shared host, not vps.
I have 2 problems here:
When I overwrite picture in public folder, the picture won't changed. But if i checked on file manager on cpanel, it actually changed, and when I copy the image address and paste it on other tabs it doesn't changed until I refresh it, the image changed so do in the web. I'm using Laravel Image Intervention to uploading image, i guess it's don't have problem with library.
For this problem, I just write
Image::make($imgDriver->getRealPath())->save($pathDriver); to upload the images. I've tried to use File::delete before overwriting the image, but it doesn't solve the problem.
The second error is, sometimes i stucked on redirect loop, and I don't know why, all I do was clearing cache to fix it. Do i really need to clean the cache everytime it shows redirect loop. Any other way to solve it?
I'm using Route::controller to route. Is it the problem?
I really appreciate any help. Thank you

Your browser is likely caching the image, rather than your hosting provider. If you use Google Chrome, there is a setting to disable cache, which is handy for development. If you want the image to update in your code, append the timestamp to the end of the image in your HTML, e.g. <img src="my_image.jpg?ts=12345">. If you use the timestamp when the image was uploaded, it will change everything a new image is uploaded, effectively loading the new version without clearing cache.
The redirect look is likely to be a session issue, where you're saving or updating something in the session, causing a redirect loop to occur. This can be painful to debug, but the best thing to do is add debug code to the affected routes / functions to narrow down the cause, e.g. using dd("i'm here") to see which block of code could be responsible.

Related

Replaced files are not replaced on server (cPanel)

So this is my problem. I replace an image with the same name on server (cpanel) and it is still showing the old image, this is happening with other files too, and even if I delete the image it is still there on the site. How do I fix this?
Clear everything.
Even if you think you have, just be safe and clear your cookies and cached images for your site.
The other possibility is that you've named it the same but with a wrong case. Remember HTML and PHP is case sensitive when looking at file names.
Let me know after you've attempted these.

Laravel development on remote server experiences CSS/JavaScript change delays

I develop on a remote server. I'm not sure if this is a laravel caching tendancy, but CSS and JavaScript changes tend to be delayed longer than usual. I can make instant HTML and php changes, but sometimes it takes more than a few minutes for CSS and JavaScript changes to be reflected on a page. I do know that .blade.php files are generated and cached within an app/storage/views folder, but even when I delete those the changes are not reflected right away.
I have tried on Chrome and Firefox.
Any ideas? Thanks!
CSS and Javascript are not handled by Laravel.
You can check it from the .htaccess of the public folder
Most likely you are hitting the cache browser. One solution to avoid browser cache is to append to the css or javascript a unique identifier whenever there is a new release, e.g.:
site/my/css.css?12345
^
|
+ - Change this to force a fresh copy
What ended up working best was to clear the cached views on the server, as #dynamic hinted at (Laravel and Blade store these cached files).
AS WELL, to close the tab completely and re-access the webpage fresh. There were cases where it was still cached, and so I would just switch to another browser.

Rackspace / Openstack PHP sdk CDN clearing out cache after upload

I am currently using an implementation of the php sdk for rackspace to upload files to a container called testcontainer. I am using a library that interacts with the sdk but I think I'll need to write it natively to accomplish what I'm looking for. Before I do this I haven't been having much luck finding out how to clear rackspace's cache.
The problem I run into (in case its not a caching issue for whatever reason) is...
Upload a file called test.jpg
visit the cdn endpoint /test.jpg and see my image
locally change the image to something else but keep the name test.jpg.
Upload the file to the same cdn container replacing the other test.jpg.
visit the cdn endpoint/test.jpg however the image is still the original test.jpg, not my new image.
This looks like a caching issue, I know in your account you can clear the cache and reset it but haven't been able to find any reference in the documentation.
Any ideas? Thanks.
If you have set your CloudFiles containers as CDN what you are seeing is indeed a caching issue. Unfortunately there's no practical way to flush the caches at scale and even if it was just one object, it could take minutes to be propagated globally. For more info how to flush CDN caches for individual objects and limits thereof, please see: here.
And of special attention:
You can use the DELETE operation against a maximum of 25 objects per day using the API

Development phase: php keeps displaying images that have been deleted

I am in the development phase of my project. I am using WAMP, Dreamweaver, and IE9. Recently I changed the color of one of the image in my source folder. The problem is that when calling a php page via WAMP the image displayed is the old one (which does not exist anymore(?)) not the new one. It only happens with php pages. It works fine with html pages.
So I believe the problem is not coming from Dreamweaver or IE9. It comes from WAMP. Looks like my old image is saved somewhere (but where?) and for some strange reasons WAMP is loading it instead of the new image.
Has anyone of you met this problem before? How to solve that? Thanks.
Websites will store images in cache once it has loaded it from your website. This is to avoid redownloading a file that hasn't changed. Sometimes, however, the files have changed and the browser is still serving the cached version. There are a few ways to get rid of this.
Clear your cache
Set you browser to not cache images
Some browsers will offer "private browsing". Not only will this not store things like cookies and history, but it will also not cache images. At least, it will only cache them until the private browsing window is closed.
Add a querystring to any file you want to serve with a timestamp like <link href="styles.css?version=213948183214 />. This is typically for development purposes, though. You wouldn't want to do this in production unless it is essential.
Some browsers offer a "hard-refresh" like Chrome and Firefox. If you hold shift while reloading, it will refresh all served files with a fresh version.
Open the page in a new browser

Chrome will not display current image / really weird

Just 30 mins ago I ran into a really unexpected problem (which as a matter of fact happened to me for the 1st time in my life, and in the 10 years of coding websites).
On a particular page from my admin module, few images reverted to their old state, the exact way they were few days ago. Which means I changed them yesterday, and now they all look like they were before.
It gets more weird. I logged in with Filezilla, and deleted the images. They still appear, with the way they looked 3 days ago, before I changed them.
If I go to the URL of the image it still displays the old images. If I look locally in my Windows folder they are the new version, upload them again, still the browser displays the old version.
I erased the cache in Chrome, even restarted the computer thinking there is something to do with Chrome or something, i really ran out of options. Firefox displays the same, the old images (even if i uploaded the new version of images).
I tried with CPanel FTP manager and...surprise...if i look at an image, it's the good version of images (the new one!). But all browsers fail to see the image.
Also as a keypoint, if I erase the image with ftp, the browser still sees it (SHIFT + f5, still it sees it, so it's not from cache). ?!?!
ANy pointing to the problem is really appreciate. Cheers
Sounds like your hosting provider has a reverse proxy that caches requests for images. One way to overcome the problem is to add something to the URL, perhaps a request parameter, that makes the proxy think that the request is not for the same image.
For example, http://www.example.com/yourimage.png?date=2012-10-25
Sounds like the hosting provider is screwing you over, so I'd say step one is to dump them and move elsewhere...
But if Joni's suggestion doesn't work, you can build your image dynamically on the server, like:
<img src="imageHandler.php?image=myimage.png" />
Your imageHandler.php code would need to read the bytes of the image, and build the HTTP response manually and pass the image bytes back. Not sure what that would look like in PHP, but it shouldn't be more than a few lines of code.
This is a terrible solution, since it would require a ton of processing and disk access for a trivial task like pulling images, but I'd expect that it would at least work.
it's the first time i answer my own question cause it was related to external factors.
yes, problem was fixed, it was actually the guys at tech. dept. at the ISP i have the files hosted, the virtual hosts config file for my domain xxx.net was ..misconfigured.
cheers all, problem is fixed

Categories