07/31
If you have used the iPhone facebook app for very long then you have probably noticed that the app runs quite a bit slower now compared to just after you first installed it, especially posting. The slow-down issue can be fixed by uninstalling the facebook app then reinstalling. That is easy enough but who wants to uninstall and reinstall all the time? This fix is only temporary.
The issue is caused by the app caching all facebook posts, photos and other data, indefinitely. The data is never deleted and each cache file is checked/updated every time the app attempts to post. That doesn’t seem very efficient but, based on my observations, that appears to be exactly what is going on every time the facebook app runs/posts. Besides waiting for facebook to “fix” their app, there is an alternative, if you don’t mind doing a little one-time setup work as described below.
Note: The following instructions assume you are using an iPhone that has been jail-broken and you have SSH and terminal access to the iPhone.
To permanently resolve the facebook app slow-down issue I created a script that will delete all of the cached files on a scheduled basis. The cached data is really only useful for about a day any way. Removing the cache files has no other affect on the facebook app since all of the data is still stored on facebook. The app will re-download anything it really needs. I chose to schedule the script to run at 4:00am every day on my iPhone but you can modify the plist file below to run at any time you like.
Steps to implement the facebook slow-down fix on your iPhone (tested on iOS 3.1.3):
- Find your facebook app GUID by running the following command. The GUID will look something like (B81C7FF4-78B8-4898-8BFC-DA83AFEA8E95):
find /User/Applications/*/Facebook.app/Facebook
- Create a new file named /usr/bin/fixfacebook.sh and insert the following content. Note, you must replace each ?????????? with the facebook app GUID from the previous step. This is the cleanup script:
#!/bin/sh echo Removing facebook cache files... rm /User/Applications/??????????/Library/Caches/Three20/0* rm /User/Applications/??????????/Library/Caches/Three20/1* rm /User/Applications/??????????/Library/Caches/Three20/2* rm /User/Applications/??????????/Library/Caches/Three20/3* rm /User/Applications/??????????/Library/Caches/Three20/4* rm /User/Applications/??????????/Library/Caches/Three20/5* rm /User/Applications/??????????/Library/Caches/Three20/6* rm /User/Applications/??????????/Library/Caches/Three20/7* rm /User/Applications/??????????/Library/Caches/Three20/8* rm /User/Applications/??????????/Library/Caches/Three20/9* rm /User/Applications/??????????/Library/Caches/Three20/a* rm /User/Applications/??????????/Library/Caches/Three20/b* rm /User/Applications/??????????/Library/Caches/Three20/c* rm /User/Applications/??????????/Library/Caches/Three20/d* rm /User/Applications/??????????/Library/Caches/Three20/e* rm /User/Applications/??????????/Library/Caches/Three20/f*
Note: If you are wondering why there are so many rm (delete) commands, it is because sometimes there are so many cache files that the rm command will refuse to delete that many files at once! Running multiple wildcard deletes will avoid this issue. - Create a new file named /Library/LaunchDaemons/com.krahmersoft.fixfacebook.plist and insert the following content. This is the scheduling information:
<?xml version="1.0? encoding="UTF-8??> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0?> <dict> <key>Label</key> <string>com.krahmersoft.fixfacebook</string> <key>OnDemand</key> <true/> <key>Program</key> <string>/usr/bin/fixfacebook.sh</string> <key>StartCalendarInterval</key> <dict> <key>Hour</key> <integer>4</integer> <key>Minute</key> <integer>0</integer> </dict> </dict> </plist>
- Run the following command to make the script executable:
chmod 755 /usr/bin/fixfacebook.sh
- Run the following command to preform the cleanup immediately. Beware, this could take several minutes to run if you have been using the facebook app for a while:
/usr/bin/fixfacebook.sh
- Run the following command to activate the schedule:
launchctl load /Library/LaunchDaemons/com.krahmersoft.fixfacebook.plist
Please post a comment if you found this information helpful!