Tease them. Make sure they want to hear the rest of the story, they want to see the plot progressing and the combat is but a mean to that end.
More specifically, there is one thing I have always found important and my DM's have virtually never used: player backstories.
We all have our players write backgrounds for their characters, but how often do we use them to generate personal stories/quests that are meaningful to one (or more) of them every so and then?
I honestly think that's the core of making quests interesting for the players, making them involve their characters' personalities as much as possible, whether through their past or their current mentality.
Every D&D player creates a character and throughout all of his sessions he/she keeps thinking of imaginary plots with his PC in the spotlight, desiring moments of him standing there, being the cool protagonist of the story as the camera focuses on his reactions while the story goes on.
So, maybe DMs should need to give out a little more of that to their players. Give them turns being awesome. How can anyone resist that? ;)
I have never GMed pathfinder, but I understand it is extremely similar to DnD where I have a fair bit of experience.
Make it fit the encounter
I generally try to make the treasure fit the encounter in the sense that the treasure should be what the creature would logically have. Under most circumstances that means I totally ignore both what the players want and the wealth by level as well as the guidelines.
So, the phase spiders you mentioned would likely have nothing but their venom. A group of goblins would have some simple spears and some simple bows and arrows. For things like that, loot is fairly simple to come up with on the fly as "What would they have?"
A group of full on humanoids is more intersting as those tend to come with equipment, but then the group finds the equipment they were using pluse whatever loot the bandits collected so far. That of course is a bit harder to come up with on the fly, but I'm still being guided by quickly thinking of what equipment did I have them use and what would they likely have.
Now of course, someone might come back by pointing out (as some players have with me) that those threats can kill adventurers and might have some adventurer equipment, so occassionally I sprinkle in something else, but then I literally just make it up on the spot and it is normally generic and low level (after all, if the adventurer that encountered these things before was powerful enough to defeat it or even get away, that equipment wouldn't be there now, so the equipment they find from random encounters will always be much weaker than what they have.)
Quests
I think that scheme has the advantage of keeping things realistic and for most encounters, especially the occassional random encounter, and makes loot easy to generate on the fly. But it has the horrible disadvantage of making meaningful loot from that kind of encounter nearly nonexistent and would leave them way behind in the wealth by level charts.
But when I GM I generally expect the players to get most of their wealth through quests. Most quests will come in the form of someone hiring the band of heroes and paying them very well for their services. If the employer/quest-giver is well connected the heroes might be able to directly bargain with the employer to get them a hard to acquire item they want in place of some of the gold initially offered.
When the story says that the quest-giver can't pay them well because they are poor themselves, then I have the quest giver reward them with information which leads to another quest which has a direct payoff. For instance, an old widow's son has been turned into a lycanthrope. The heroes rescue him and turn him back. The old widow can't pay them directly, but she knows the old local story about the Archmage Generet from over 200 years ago who died leaving behind his tower. The tower is reputed to hold his great wealth but remains home to the remains of his experiments so it is too dangerous for any of the locals to go to.
The loot from the tower will fit with what an archamge would likely have lying around and is meant to compensate for the work on the lycanthrope so it will be far richer than the threat level of the gaurdians would suggest by the book. But I still fill it by thinking mostly about the kinds of things an archmage would have lying around. They will find things like potions, wands, components, and scrolls in abundance, but probably not a set of plate mail. If they want a set of enchanged plate mail, they will either sell off the loot to buy it or else they will start asking around specifically for a lead to that sort of quest.
Getting them what they want
Which brings me to leads. In games I run, the players buy most of the equipment they specifically want. But if they want something truly exotic where buying it won't work and they can't negotiate for it from a quest giver, then they need to look for a lead. A lead is normally the start of quest meant to bring them to exactly what they want.
So, the Paladin needs a new set of armor, but not just any set, he wants a legendary one. His player tells me ooc, and in character starts asking around. No one can sell him something like that, but eventually someone will tell him the story of Sir Gawain the Kind who was killed by the dragon Karlesto. Sir Gawain had a set and it likely is now in Karlesto's possession. No one is paying to have the dragon killed because it has been inactive for decades...but if they do kill it they will likely find his set of armor along with the gold the dragon has been hoarding.
Best Answer
Hooks and Cliffhangers
One thing that you should have plenty of is hooks, rather than spend all of them during the session, you can save a couple for when things start to drag on.
That journal can be core-plot relevant or side-plot relevant, but whatever it is, it can be used to distract the players from the slog. It is something new and interesting that they will question immediately (hopefully) and likely steer them towards things both you and they find interesting.
When the session is about to end, you can use this technique as an opportunity to place that interest onto the next session.
And that's where we'll leave off.
There is an art to this, deciding when in the middle of a hook to stop the storytelling. You want to give the players just enough info for them to know something is happening next, but get in the way of them being able to resolve it during this session by fading to black.
Their minds are already thinking "what would be my next course of action" but without the opportunity to get the feedback of actually doing anything, this will build up anticipation for the next session when they will actually get to see the plan that's flashed through their heads, or the courses of action they've talked about amongst themselves between sessions, or the crazy ideas they've thought of in the meantime that might actually be worth trying.
Don't do this too often.
Sometimes, it's important for sessions to just have lulls in them. Once you've overcome a major arc, the players don't need to be put to the blade again so soon. Repeated pressure to "do the next thing" can lead to player burnout and might be more stressful. This is a balance you need to learn with your players and it's not something I can really give a good rule of thumb for. Keep an eye on your players and see if they're trying to accomplish something in game that is getting interrupted by these hooks. If players are willing to pick their own pace and trajectory, this saves you some work and guarantees they're invested.