The problem with displaying / disabling the image when using Vagrant to develop HAML / SASS

I make HAML / SASS changes for a Rails application that I run locally using Vagrant / VirtualBox VM on Mac OSX (Snow Leopard), and I constantly encounter a really strange problem when I make changes to the link image in any of the HAML / SASS.

Here is an example of what is happening:

  • I open the local page of the Rails application in my browser and all the images are displayed correctly.
  • I am resizing the image (using Gimp) to reduce it and save the changes.
  • I refresh the page to see the changes, and the original image is still displayed, but when lowering the bottom, depending on how much less I made the image
  • I delete the image file from the directory and hard-refresh the page to see what happens.
  • Sometimes the original clipping image still exists, sometimes it disappears, and I just see the path icon for the missing image.
  • I move the image file back to the directory to try to get it to resize again
  • Sometimes it works the first time, sometimes I have to do it 3 or 4 times before I see an image with the correct size.
  • Sometimes I see that the old cropped image appears again even after refreshing the page and did not see the image!

The same problem occurs if I make other changes to the image file (for example, if I save a completely new image with the same file name). Besides this problem with images, all changes in HAML / SASS files work, and I can instantly see my changes.

I thought it might be some kind of browser rendering / caching problem, but similar problems occur in Firefox and Chrome. If I use Firebug, I sometimes see that the correct file is being selected, but it does not appear on the page itself.

I can only think that this has something to do with Wagrant. The only thing guaranteed to fix this completely is to ban the Vagrant box, but it takes a lot of time.

I understand that this may not be a simple problem, as it may have something to do with our Rails application and setting up Vagrant / VirtualBox, but I just thought I would post this problem here if someone else had this questions.

Thanks!

+4
source share
1 answer

What you probably see is the problem that the file system is associated with the VirtualBox shared folder along with the syscall sendfile . You need to disable the use of sendfile on your web server if you use files from the VirtualBox shared folder. This is easy:

On Apache, add this to your configuration: EnableSendfile off

In Nginx, add this to your configuration: sendfile off;

+2
source

Source: https://habr.com/ru/post/1400751/


All Articles